1*ec02198aSmrg@c Copyright (C) 2004-2020 Free Software Foundation, Inc. 210d565efSmrg@c This is part of the GCC manual. 310d565efSmrg@c For copying conditions, see the file gcc.texi. 410d565efSmrg 510d565efSmrg@c --------------------------------------------------------------------- 610d565efSmrg@c GENERIC 710d565efSmrg@c --------------------------------------------------------------------- 810d565efSmrg 910d565efSmrg@node GENERIC 1010d565efSmrg@chapter GENERIC 1110d565efSmrg@cindex GENERIC 1210d565efSmrg 1310d565efSmrgThe purpose of GENERIC is simply to provide a 1410d565efSmrglanguage-independent way of representing an entire function in 1510d565efSmrgtrees. To this end, it was necessary to add a few new tree codes 1610d565efSmrgto the back end, but almost everything was already there. If you 1710d565efSmrgcan express it with the codes in @code{gcc/tree.def}, it's 1810d565efSmrgGENERIC@. 1910d565efSmrg 2010d565efSmrgEarly on, there was a great deal of debate about how to think 2110d565efSmrgabout statements in a tree IL@. In GENERIC, a statement is 2210d565efSmrgdefined as any expression whose value, if any, is ignored. A 2310d565efSmrgstatement will always have @code{TREE_SIDE_EFFECTS} set (or it 2410d565efSmrgwill be discarded), but a non-statement expression may also have 2510d565efSmrgside effects. A @code{CALL_EXPR}, for instance. 2610d565efSmrg 2710d565efSmrgIt would be possible for some local optimizations to work on the 2810d565efSmrgGENERIC form of a function; indeed, the adapted tree inliner 2910d565efSmrgworks fine on GENERIC, but the current compiler performs inlining 3010d565efSmrgafter lowering to GIMPLE (a restricted form described in the next 3110d565efSmrgsection). Indeed, currently the frontends perform this lowering 3210d565efSmrgbefore handing off to @code{tree_rest_of_compilation}, but this 3310d565efSmrgseems inelegant. 3410d565efSmrg 3510d565efSmrg@menu 3610d565efSmrg* Deficiencies:: Topics net yet covered in this document. 3710d565efSmrg* Tree overview:: All about @code{tree}s. 3810d565efSmrg* Types:: Fundamental and aggregate types. 3910d565efSmrg* Declarations:: Type declarations and variables. 4010d565efSmrg* Attributes:: Declaration and type attributes. 4110d565efSmrg* Expressions: Expression trees. Operating on data. 4210d565efSmrg* Statements:: Control flow and related trees. 4310d565efSmrg* Functions:: Function bodies, linkage, and other aspects. 4410d565efSmrg* Language-dependent trees:: Topics and trees specific to language front ends. 4510d565efSmrg* C and C++ Trees:: Trees specific to C and C++. 4610d565efSmrg@end menu 4710d565efSmrg 4810d565efSmrg@c --------------------------------------------------------------------- 4910d565efSmrg@c Deficiencies 5010d565efSmrg@c --------------------------------------------------------------------- 5110d565efSmrg 5210d565efSmrg@node Deficiencies 5310d565efSmrg@section Deficiencies 5410d565efSmrg 5510d565efSmrg@c The spelling of "incomplet" and "incorrekt" below is intentional. 5610d565efSmrgThere are many places in which this document is incomplet and incorrekt. 5710d565efSmrgIt is, as of yet, only @emph{preliminary} documentation. 5810d565efSmrg 5910d565efSmrg@c --------------------------------------------------------------------- 6010d565efSmrg@c Overview 6110d565efSmrg@c --------------------------------------------------------------------- 6210d565efSmrg 6310d565efSmrg@node Tree overview 6410d565efSmrg@section Overview 6510d565efSmrg@cindex tree 6610d565efSmrg@findex TREE_CODE 6710d565efSmrg 6810d565efSmrgThe central data structure used by the internal representation is the 6910d565efSmrg@code{tree}. These nodes, while all of the C type @code{tree}, are of 7010d565efSmrgmany varieties. A @code{tree} is a pointer type, but the object to 7110d565efSmrgwhich it points may be of a variety of types. From this point forward, 7210d565efSmrgwe will refer to trees in ordinary type, rather than in @code{this 7310d565efSmrgfont}, except when talking about the actual C type @code{tree}. 7410d565efSmrg 7510d565efSmrgYou can tell what kind of node a particular tree is by using the 7610d565efSmrg@code{TREE_CODE} macro. Many, many macros take trees as input and 7710d565efSmrgreturn trees as output. However, most macros require a certain kind of 7810d565efSmrgtree node as input. In other words, there is a type-system for trees, 7910d565efSmrgbut it is not reflected in the C type-system. 8010d565efSmrg 8110d565efSmrgFor safety, it is useful to configure GCC with @option{--enable-checking}. 8210d565efSmrgAlthough this results in a significant performance penalty (since all 8310d565efSmrgtree types are checked at run-time), and is therefore inappropriate in a 8410d565efSmrgrelease version, it is extremely helpful during the development process. 8510d565efSmrg 8610d565efSmrgMany macros behave as predicates. Many, although not all, of these 8710d565efSmrgpredicates end in @samp{_P}. Do not rely on the result type of these 8810d565efSmrgmacros being of any particular type. You may, however, rely on the fact 8910d565efSmrgthat the type can be compared to @code{0}, so that statements like 9010d565efSmrg@smallexample 9110d565efSmrgif (TEST_P (t) && !TEST_P (y)) 9210d565efSmrg x = 1; 9310d565efSmrg@end smallexample 9410d565efSmrg@noindent 9510d565efSmrgand 9610d565efSmrg@smallexample 9710d565efSmrgint i = (TEST_P (t) != 0); 9810d565efSmrg@end smallexample 9910d565efSmrg@noindent 10010d565efSmrgare legal. Macros that return @code{int} values now may be changed to 10110d565efSmrgreturn @code{tree} values, or other pointers in the future. Even those 10210d565efSmrgthat continue to return @code{int} may return multiple nonzero codes 10310d565efSmrgwhere previously they returned only zero and one. Therefore, you should 10410d565efSmrgnot write code like 10510d565efSmrg@smallexample 10610d565efSmrgif (TEST_P (t) == 1) 10710d565efSmrg@end smallexample 10810d565efSmrg@noindent 10910d565efSmrgas this code is not guaranteed to work correctly in the future. 11010d565efSmrg 11110d565efSmrgYou should not take the address of values returned by the macros or 11210d565efSmrgfunctions described here. In particular, no guarantee is given that the 11310d565efSmrgvalues are lvalues. 11410d565efSmrg 11510d565efSmrgIn general, the names of macros are all in uppercase, while the names of 11610d565efSmrgfunctions are entirely in lowercase. There are rare exceptions to this 11710d565efSmrgrule. You should assume that any macro or function whose name is made 11810d565efSmrgup entirely of uppercase letters may evaluate its arguments more than 11910d565efSmrgonce. You may assume that a macro or function whose name is made up 12010d565efSmrgentirely of lowercase letters will evaluate its arguments only once. 12110d565efSmrg 12210d565efSmrgThe @code{error_mark_node} is a special tree. Its tree code is 12310d565efSmrg@code{ERROR_MARK}, but since there is only ever one node with that code, 12410d565efSmrgthe usual practice is to compare the tree against 12510d565efSmrg@code{error_mark_node}. (This test is just a test for pointer 12610d565efSmrgequality.) If an error has occurred during front-end processing the 12710d565efSmrgflag @code{errorcount} will be set. If the front end has encountered 12810d565efSmrgcode it cannot handle, it will issue a message to the user and set 12910d565efSmrg@code{sorrycount}. When these flags are set, any macro or function 13010d565efSmrgwhich normally returns a tree of a particular kind may instead return 13110d565efSmrgthe @code{error_mark_node}. Thus, if you intend to do any processing of 13210d565efSmrgerroneous code, you must be prepared to deal with the 13310d565efSmrg@code{error_mark_node}. 13410d565efSmrg 13510d565efSmrgOccasionally, a particular tree slot (like an operand to an expression, 13610d565efSmrgor a particular field in a declaration) will be referred to as 13710d565efSmrg``reserved for the back end''. These slots are used to store RTL when 13810d565efSmrgthe tree is converted to RTL for use by the GCC back end. However, if 13910d565efSmrgthat process is not taking place (e.g., if the front end is being hooked 14010d565efSmrgup to an intelligent editor), then those slots may be used by the 14110d565efSmrgback end presently in use. 14210d565efSmrg 14310d565efSmrgIf you encounter situations that do not match this documentation, such 14410d565efSmrgas tree nodes of types not mentioned here, or macros documented to 14510d565efSmrgreturn entities of a particular kind that instead return entities of 14610d565efSmrgsome different kind, you have found a bug, either in the front end or in 14710d565efSmrgthe documentation. Please report these bugs as you would any other 14810d565efSmrgbug. 14910d565efSmrg 15010d565efSmrg@menu 15110d565efSmrg* Macros and Functions::Macros and functions that can be used with all trees. 15210d565efSmrg* Identifiers:: The names of things. 15310d565efSmrg* Containers:: Lists and vectors. 15410d565efSmrg@end menu 15510d565efSmrg 15610d565efSmrg@c --------------------------------------------------------------------- 15710d565efSmrg@c Trees 15810d565efSmrg@c --------------------------------------------------------------------- 15910d565efSmrg 16010d565efSmrg@node Macros and Functions 16110d565efSmrg@subsection Trees 16210d565efSmrg@cindex tree 16310d565efSmrg@findex TREE_CHAIN 16410d565efSmrg@findex TREE_TYPE 16510d565efSmrg 16610d565efSmrgAll GENERIC trees have two fields in common. First, @code{TREE_CHAIN} 16710d565efSmrgis a pointer that can be used as a singly-linked list to other trees. 16810d565efSmrgThe other is @code{TREE_TYPE}. Many trees store the type of an 16910d565efSmrgexpression or declaration in this field. 17010d565efSmrg 17110d565efSmrgThese are some other functions for handling trees: 17210d565efSmrg 17310d565efSmrg@ftable @code 17410d565efSmrg 17510d565efSmrg@item tree_size 17610d565efSmrgReturn the number of bytes a tree takes. 17710d565efSmrg 17810d565efSmrg@item build0 17910d565efSmrg@itemx build1 18010d565efSmrg@itemx build2 18110d565efSmrg@itemx build3 18210d565efSmrg@itemx build4 18310d565efSmrg@itemx build5 18410d565efSmrg@itemx build6 18510d565efSmrg 18610d565efSmrgThese functions build a tree and supply values to put in each 18710d565efSmrgparameter. The basic signature is @samp{@w{code, type, [operands]}}. 18810d565efSmrg@code{code} is the @code{TREE_CODE}, and @code{type} is a tree 18910d565efSmrgrepresenting the @code{TREE_TYPE}. These are followed by the 19010d565efSmrgoperands, each of which is also a tree. 19110d565efSmrg 19210d565efSmrg@end ftable 19310d565efSmrg 19410d565efSmrg 19510d565efSmrg@c --------------------------------------------------------------------- 19610d565efSmrg@c Identifiers 19710d565efSmrg@c --------------------------------------------------------------------- 19810d565efSmrg 19910d565efSmrg@node Identifiers 20010d565efSmrg@subsection Identifiers 20110d565efSmrg@cindex identifier 20210d565efSmrg@cindex name 20310d565efSmrg@tindex IDENTIFIER_NODE 20410d565efSmrg 20510d565efSmrgAn @code{IDENTIFIER_NODE} represents a slightly more general concept 20610d565efSmrgthan the standard C or C++ concept of identifier. In particular, an 20710d565efSmrg@code{IDENTIFIER_NODE} may contain a @samp{$}, or other extraordinary 20810d565efSmrgcharacters. 20910d565efSmrg 21010d565efSmrgThere are never two distinct @code{IDENTIFIER_NODE}s representing the 21110d565efSmrgsame identifier. Therefore, you may use pointer equality to compare 21210d565efSmrg@code{IDENTIFIER_NODE}s, rather than using a routine like 21310d565efSmrg@code{strcmp}. Use @code{get_identifier} to obtain the unique 21410d565efSmrg@code{IDENTIFIER_NODE} for a supplied string. 21510d565efSmrg 21610d565efSmrgYou can use the following macros to access identifiers: 21710d565efSmrg@ftable @code 21810d565efSmrg@item IDENTIFIER_POINTER 21910d565efSmrgThe string represented by the identifier, represented as a 22010d565efSmrg@code{char*}. This string is always @code{NUL}-terminated, and contains 22110d565efSmrgno embedded @code{NUL} characters. 22210d565efSmrg 22310d565efSmrg@item IDENTIFIER_LENGTH 22410d565efSmrgThe length of the string returned by @code{IDENTIFIER_POINTER}, not 22510d565efSmrgincluding the trailing @code{NUL}. This value of 22610d565efSmrg@code{IDENTIFIER_LENGTH (x)} is always the same as @code{strlen 22710d565efSmrg(IDENTIFIER_POINTER (x))}. 22810d565efSmrg 22910d565efSmrg@item IDENTIFIER_OPNAME_P 23010d565efSmrgThis predicate holds if the identifier represents the name of an 23110d565efSmrgoverloaded operator. In this case, you should not depend on the 23210d565efSmrgcontents of either the @code{IDENTIFIER_POINTER} or the 23310d565efSmrg@code{IDENTIFIER_LENGTH}. 23410d565efSmrg 23510d565efSmrg@item IDENTIFIER_TYPENAME_P 23610d565efSmrgThis predicate holds if the identifier represents the name of a 23710d565efSmrguser-defined conversion operator. In this case, the @code{TREE_TYPE} of 23810d565efSmrgthe @code{IDENTIFIER_NODE} holds the type to which the conversion 23910d565efSmrgoperator converts. 24010d565efSmrg 24110d565efSmrg@end ftable 24210d565efSmrg 24310d565efSmrg@c --------------------------------------------------------------------- 24410d565efSmrg@c Containers 24510d565efSmrg@c --------------------------------------------------------------------- 24610d565efSmrg 24710d565efSmrg@node Containers 24810d565efSmrg@subsection Containers 24910d565efSmrg@cindex container 25010d565efSmrg@cindex list 25110d565efSmrg@cindex vector 25210d565efSmrg@tindex TREE_LIST 25310d565efSmrg@tindex TREE_VEC 25410d565efSmrg@findex TREE_PURPOSE 25510d565efSmrg@findex TREE_VALUE 25610d565efSmrg@findex TREE_VEC_LENGTH 25710d565efSmrg@findex TREE_VEC_ELT 25810d565efSmrg 25910d565efSmrgTwo common container data structures can be represented directly with 26010d565efSmrgtree nodes. A @code{TREE_LIST} is a singly linked list containing two 26110d565efSmrgtrees per node. These are the @code{TREE_PURPOSE} and @code{TREE_VALUE} 26210d565efSmrgof each node. (Often, the @code{TREE_PURPOSE} contains some kind of 26310d565efSmrgtag, or additional information, while the @code{TREE_VALUE} contains the 26410d565efSmrgmajority of the payload. In other cases, the @code{TREE_PURPOSE} is 26510d565efSmrgsimply @code{NULL_TREE}, while in still others both the 26610d565efSmrg@code{TREE_PURPOSE} and @code{TREE_VALUE} are of equal stature.) Given 26710d565efSmrgone @code{TREE_LIST} node, the next node is found by following the 26810d565efSmrg@code{TREE_CHAIN}. If the @code{TREE_CHAIN} is @code{NULL_TREE}, then 26910d565efSmrgyou have reached the end of the list. 27010d565efSmrg 27110d565efSmrgA @code{TREE_VEC} is a simple vector. The @code{TREE_VEC_LENGTH} is an 27210d565efSmrginteger (not a tree) giving the number of nodes in the vector. The 27310d565efSmrgnodes themselves are accessed using the @code{TREE_VEC_ELT} macro, which 27410d565efSmrgtakes two arguments. The first is the @code{TREE_VEC} in question; the 27510d565efSmrgsecond is an integer indicating which element in the vector is desired. 27610d565efSmrgThe elements are indexed from zero. 27710d565efSmrg 27810d565efSmrg@c --------------------------------------------------------------------- 27910d565efSmrg@c Types 28010d565efSmrg@c --------------------------------------------------------------------- 28110d565efSmrg 28210d565efSmrg@node Types 28310d565efSmrg@section Types 28410d565efSmrg@cindex type 28510d565efSmrg@cindex pointer 28610d565efSmrg@cindex reference 28710d565efSmrg@cindex fundamental type 28810d565efSmrg@cindex array 28910d565efSmrg@tindex VOID_TYPE 29010d565efSmrg@tindex INTEGER_TYPE 29110d565efSmrg@tindex TYPE_MIN_VALUE 29210d565efSmrg@tindex TYPE_MAX_VALUE 29310d565efSmrg@tindex REAL_TYPE 29410d565efSmrg@tindex FIXED_POINT_TYPE 29510d565efSmrg@tindex COMPLEX_TYPE 29610d565efSmrg@tindex ENUMERAL_TYPE 29710d565efSmrg@tindex BOOLEAN_TYPE 29810d565efSmrg@tindex POINTER_TYPE 29910d565efSmrg@tindex REFERENCE_TYPE 30010d565efSmrg@tindex FUNCTION_TYPE 30110d565efSmrg@tindex METHOD_TYPE 30210d565efSmrg@tindex ARRAY_TYPE 30310d565efSmrg@tindex RECORD_TYPE 30410d565efSmrg@tindex UNION_TYPE 30510d565efSmrg@tindex UNKNOWN_TYPE 30610d565efSmrg@tindex OFFSET_TYPE 30710d565efSmrg@findex TYPE_UNQUALIFIED 30810d565efSmrg@findex TYPE_QUAL_CONST 30910d565efSmrg@findex TYPE_QUAL_VOLATILE 31010d565efSmrg@findex TYPE_QUAL_RESTRICT 31110d565efSmrg@findex TYPE_MAIN_VARIANT 31210d565efSmrg@cindex qualified type 31310d565efSmrg@findex TYPE_SIZE 31410d565efSmrg@findex TYPE_ALIGN 31510d565efSmrg@findex TYPE_PRECISION 31610d565efSmrg@findex TYPE_ARG_TYPES 31710d565efSmrg@findex TYPE_METHOD_BASETYPE 31810d565efSmrg@findex TYPE_OFFSET_BASETYPE 31910d565efSmrg@findex TREE_TYPE 32010d565efSmrg@findex TYPE_CONTEXT 32110d565efSmrg@findex TYPE_NAME 32210d565efSmrg@findex TYPENAME_TYPE_FULLNAME 32310d565efSmrg@findex TYPE_FIELDS 32410d565efSmrg@findex TYPE_CANONICAL 32510d565efSmrg@findex TYPE_STRUCTURAL_EQUALITY_P 32610d565efSmrg@findex SET_TYPE_STRUCTURAL_EQUALITY 32710d565efSmrg 32810d565efSmrgAll types have corresponding tree nodes. However, you should not assume 32910d565efSmrgthat there is exactly one tree node corresponding to each type. There 33010d565efSmrgare often multiple nodes corresponding to the same type. 33110d565efSmrg 33210d565efSmrgFor the most part, different kinds of types have different tree codes. 33310d565efSmrg(For example, pointer types use a @code{POINTER_TYPE} code while arrays 33410d565efSmrguse an @code{ARRAY_TYPE} code.) However, pointers to member functions 33510d565efSmrguse the @code{RECORD_TYPE} code. Therefore, when writing a 33610d565efSmrg@code{switch} statement that depends on the code associated with a 33710d565efSmrgparticular type, you should take care to handle pointers to member 33810d565efSmrgfunctions under the @code{RECORD_TYPE} case label. 33910d565efSmrg 34010d565efSmrgThe following functions and macros deal with cv-qualification of types: 34110d565efSmrg@ftable @code 34210d565efSmrg@item TYPE_MAIN_VARIANT 34310d565efSmrgThis macro returns the unqualified version of a type. It may be applied 34410d565efSmrgto an unqualified type, but it is not always the identity function in 34510d565efSmrgthat case. 34610d565efSmrg@end ftable 34710d565efSmrg 34810d565efSmrgA few other macros and functions are usable with all types: 34910d565efSmrg@ftable @code 35010d565efSmrg@item TYPE_SIZE 35110d565efSmrgThe number of bits required to represent the type, represented as an 35210d565efSmrg@code{INTEGER_CST}. For an incomplete type, @code{TYPE_SIZE} will be 35310d565efSmrg@code{NULL_TREE}. 35410d565efSmrg 35510d565efSmrg@item TYPE_ALIGN 35610d565efSmrgThe alignment of the type, in bits, represented as an @code{int}. 35710d565efSmrg 35810d565efSmrg@item TYPE_NAME 35910d565efSmrgThis macro returns a declaration (in the form of a @code{TYPE_DECL}) for 36010d565efSmrgthe type. (Note this macro does @emph{not} return an 36110d565efSmrg@code{IDENTIFIER_NODE}, as you might expect, given its name!) You can 36210d565efSmrglook at the @code{DECL_NAME} of the @code{TYPE_DECL} to obtain the 36310d565efSmrgactual name of the type. The @code{TYPE_NAME} will be @code{NULL_TREE} 36410d565efSmrgfor a type that is not a built-in type, the result of a typedef, or a 36510d565efSmrgnamed class type. 36610d565efSmrg 36710d565efSmrg@item TYPE_CANONICAL 36810d565efSmrgThis macro returns the ``canonical'' type for the given type 36910d565efSmrgnode. Canonical types are used to improve performance in the C++ and 37010d565efSmrgObjective-C++ front ends by allowing efficient comparison between two 37110d565efSmrgtype nodes in @code{same_type_p}: if the @code{TYPE_CANONICAL} values 37210d565efSmrgof the types are equal, the types are equivalent; otherwise, the types 37310d565efSmrgare not equivalent. The notion of equivalence for canonical types is 37410d565efSmrgthe same as the notion of type equivalence in the language itself. For 37510d565efSmrginstance, 37610d565efSmrg 37710d565efSmrgWhen @code{TYPE_CANONICAL} is @code{NULL_TREE}, there is no canonical 37810d565efSmrgtype for the given type node. In this case, comparison between this 37910d565efSmrgtype and any other type requires the compiler to perform a deep, 38010d565efSmrg``structural'' comparison to see if the two type nodes have the same 38110d565efSmrgform and properties. 38210d565efSmrg 38310d565efSmrgThe canonical type for a node is always the most fundamental type in 38410d565efSmrgthe equivalence class of types. For instance, @code{int} is its own 38510d565efSmrgcanonical type. A typedef @code{I} of @code{int} will have @code{int} 38610d565efSmrgas its canonical type. Similarly, @code{I*}@ and a typedef @code{IP}@ 38710d565efSmrg(defined to @code{I*}) will has @code{int*} as their canonical 38810d565efSmrgtype. When building a new type node, be sure to set 38910d565efSmrg@code{TYPE_CANONICAL} to the appropriate canonical type. If the new 39010d565efSmrgtype is a compound type (built from other types), and any of those 39110d565efSmrgother types require structural equality, use 39210d565efSmrg@code{SET_TYPE_STRUCTURAL_EQUALITY} to ensure that the new type also 39310d565efSmrgrequires structural equality. Finally, if for some reason you cannot 39410d565efSmrgguarantee that @code{TYPE_CANONICAL} will point to the canonical type, 39510d565efSmrguse @code{SET_TYPE_STRUCTURAL_EQUALITY} to make sure that the new 39610d565efSmrgtype--and any type constructed based on it--requires structural 39710d565efSmrgequality. If you suspect that the canonical type system is 39810d565efSmrgmiscomparing types, pass @code{--param verify-canonical-types=1} to 39910d565efSmrgthe compiler or configure with @code{--enable-checking} to force the 40010d565efSmrgcompiler to verify its canonical-type comparisons against the 40110d565efSmrgstructural comparisons; the compiler will then print any warnings if 40210d565efSmrgthe canonical types miscompare. 40310d565efSmrg 40410d565efSmrg@item TYPE_STRUCTURAL_EQUALITY_P 40510d565efSmrgThis predicate holds when the node requires structural equality 40610d565efSmrgchecks, e.g., when @code{TYPE_CANONICAL} is @code{NULL_TREE}. 40710d565efSmrg 40810d565efSmrg@item SET_TYPE_STRUCTURAL_EQUALITY 40910d565efSmrgThis macro states that the type node it is given requires structural 41010d565efSmrgequality checks, e.g., it sets @code{TYPE_CANONICAL} to 41110d565efSmrg@code{NULL_TREE}. 41210d565efSmrg 41310d565efSmrg@item same_type_p 41410d565efSmrgThis predicate takes two types as input, and holds if they are the same 41510d565efSmrgtype. For example, if one type is a @code{typedef} for the other, or 41610d565efSmrgboth are @code{typedef}s for the same type. This predicate also holds if 41710d565efSmrgthe two trees given as input are simply copies of one another; i.e., 41810d565efSmrgthere is no difference between them at the source level, but, for 41910d565efSmrgwhatever reason, a duplicate has been made in the representation. You 42010d565efSmrgshould never use @code{==} (pointer equality) to compare types; always 42110d565efSmrguse @code{same_type_p} instead. 42210d565efSmrg@end ftable 42310d565efSmrg 42410d565efSmrgDetailed below are the various kinds of types, and the macros that can 42510d565efSmrgbe used to access them. Although other kinds of types are used 42610d565efSmrgelsewhere in G++, the types described here are the only ones that you 42710d565efSmrgwill encounter while examining the intermediate representation. 42810d565efSmrg 42910d565efSmrg@table @code 43010d565efSmrg@item VOID_TYPE 43110d565efSmrgUsed to represent the @code{void} type. 43210d565efSmrg 43310d565efSmrg@item INTEGER_TYPE 43410d565efSmrgUsed to represent the various integral types, including @code{char}, 43510d565efSmrg@code{short}, @code{int}, @code{long}, and @code{long long}. This code 43610d565efSmrgis not used for enumeration types, nor for the @code{bool} type. 43710d565efSmrgThe @code{TYPE_PRECISION} is the number of bits used in 43810d565efSmrgthe representation, represented as an @code{unsigned int}. (Note that 43910d565efSmrgin the general case this is not the same value as @code{TYPE_SIZE}; 44010d565efSmrgsuppose that there were a 24-bit integer type, but that alignment 44110d565efSmrgrequirements for the ABI required 32-bit alignment. Then, 44210d565efSmrg@code{TYPE_SIZE} would be an @code{INTEGER_CST} for 32, while 44310d565efSmrg@code{TYPE_PRECISION} would be 24.) The integer type is unsigned if 44410d565efSmrg@code{TYPE_UNSIGNED} holds; otherwise, it is signed. 44510d565efSmrg 44610d565efSmrgThe @code{TYPE_MIN_VALUE} is an @code{INTEGER_CST} for the smallest 44710d565efSmrginteger that may be represented by this type. Similarly, the 44810d565efSmrg@code{TYPE_MAX_VALUE} is an @code{INTEGER_CST} for the largest integer 44910d565efSmrgthat may be represented by this type. 45010d565efSmrg 45110d565efSmrg@item REAL_TYPE 45210d565efSmrgUsed to represent the @code{float}, @code{double}, and @code{long 45310d565efSmrgdouble} types. The number of bits in the floating-point representation 45410d565efSmrgis given by @code{TYPE_PRECISION}, as in the @code{INTEGER_TYPE} case. 45510d565efSmrg 45610d565efSmrg@item FIXED_POINT_TYPE 45710d565efSmrgUsed to represent the @code{short _Fract}, @code{_Fract}, @code{long 45810d565efSmrg_Fract}, @code{long long _Fract}, @code{short _Accum}, @code{_Accum}, 45910d565efSmrg@code{long _Accum}, and @code{long long _Accum} types. The number of bits 46010d565efSmrgin the fixed-point representation is given by @code{TYPE_PRECISION}, 46110d565efSmrgas in the @code{INTEGER_TYPE} case. There may be padding bits, fractional 46210d565efSmrgbits and integral bits. The number of fractional bits is given by 46310d565efSmrg@code{TYPE_FBIT}, and the number of integral bits is given by @code{TYPE_IBIT}. 46410d565efSmrgThe fixed-point type is unsigned if @code{TYPE_UNSIGNED} holds; otherwise, 46510d565efSmrgit is signed. 46610d565efSmrgThe fixed-point type is saturating if @code{TYPE_SATURATING} holds; otherwise, 46710d565efSmrgit is not saturating. 46810d565efSmrg 46910d565efSmrg@item COMPLEX_TYPE 47010d565efSmrgUsed to represent GCC built-in @code{__complex__} data types. The 47110d565efSmrg@code{TREE_TYPE} is the type of the real and imaginary parts. 47210d565efSmrg 47310d565efSmrg@item ENUMERAL_TYPE 47410d565efSmrgUsed to represent an enumeration type. The @code{TYPE_PRECISION} gives 47510d565efSmrg(as an @code{int}), the number of bits used to represent the type. If 47610d565efSmrgthere are no negative enumeration constants, @code{TYPE_UNSIGNED} will 47710d565efSmrghold. The minimum and maximum enumeration constants may be obtained 47810d565efSmrgwith @code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE}, respectively; each 47910d565efSmrgof these macros returns an @code{INTEGER_CST}. 48010d565efSmrg 48110d565efSmrgThe actual enumeration constants themselves may be obtained by looking 48210d565efSmrgat the @code{TYPE_VALUES}. This macro will return a @code{TREE_LIST}, 48310d565efSmrgcontaining the constants. The @code{TREE_PURPOSE} of each node will be 48410d565efSmrgan @code{IDENTIFIER_NODE} giving the name of the constant; the 48510d565efSmrg@code{TREE_VALUE} will be an @code{INTEGER_CST} giving the value 48610d565efSmrgassigned to that constant. These constants will appear in the order in 48710d565efSmrgwhich they were declared. The @code{TREE_TYPE} of each of these 48810d565efSmrgconstants will be the type of enumeration type itself. 48910d565efSmrg 49010d565efSmrg@item BOOLEAN_TYPE 49110d565efSmrgUsed to represent the @code{bool} type. 49210d565efSmrg 49310d565efSmrg@item POINTER_TYPE 49410d565efSmrgUsed to represent pointer types, and pointer to data member types. The 49510d565efSmrg@code{TREE_TYPE} gives the type to which this type points. 49610d565efSmrg 49710d565efSmrg@item REFERENCE_TYPE 49810d565efSmrgUsed to represent reference types. The @code{TREE_TYPE} gives the type 49910d565efSmrgto which this type refers. 50010d565efSmrg 50110d565efSmrg@item FUNCTION_TYPE 50210d565efSmrgUsed to represent the type of non-member functions and of static member 50310d565efSmrgfunctions. The @code{TREE_TYPE} gives the return type of the function. 50410d565efSmrgThe @code{TYPE_ARG_TYPES} are a @code{TREE_LIST} of the argument types. 50510d565efSmrgThe @code{TREE_VALUE} of each node in this list is the type of the 50610d565efSmrgcorresponding argument; the @code{TREE_PURPOSE} is an expression for the 50710d565efSmrgdefault argument value, if any. If the last node in the list is 50810d565efSmrg@code{void_list_node} (a @code{TREE_LIST} node whose @code{TREE_VALUE} 50910d565efSmrgis the @code{void_type_node}), then functions of this type do not take 51010d565efSmrgvariable arguments. Otherwise, they do take a variable number of 51110d565efSmrgarguments. 51210d565efSmrg 51310d565efSmrgNote that in C (but not in C++) a function declared like @code{void f()} 51410d565efSmrgis an unprototyped function taking a variable number of arguments; the 51510d565efSmrg@code{TYPE_ARG_TYPES} of such a function will be @code{NULL}. 51610d565efSmrg 51710d565efSmrg@item METHOD_TYPE 51810d565efSmrgUsed to represent the type of a non-static member function. Like a 51910d565efSmrg@code{FUNCTION_TYPE}, the return type is given by the @code{TREE_TYPE}. 52010d565efSmrgThe type of @code{*this}, i.e., the class of which functions of this 52110d565efSmrgtype are a member, is given by the @code{TYPE_METHOD_BASETYPE}. The 52210d565efSmrg@code{TYPE_ARG_TYPES} is the parameter list, as for a 52310d565efSmrg@code{FUNCTION_TYPE}, and includes the @code{this} argument. 52410d565efSmrg 52510d565efSmrg@item ARRAY_TYPE 52610d565efSmrgUsed to represent array types. The @code{TREE_TYPE} gives the type of 52710d565efSmrgthe elements in the array. If the array-bound is present in the type, 52810d565efSmrgthe @code{TYPE_DOMAIN} is an @code{INTEGER_TYPE} whose 52910d565efSmrg@code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE} will be the lower and 53010d565efSmrgupper bounds of the array, respectively. The @code{TYPE_MIN_VALUE} will 53110d565efSmrgalways be an @code{INTEGER_CST} for zero, while the 53210d565efSmrg@code{TYPE_MAX_VALUE} will be one less than the number of elements in 53310d565efSmrgthe array, i.e., the highest value which may be used to index an element 53410d565efSmrgin the array. 53510d565efSmrg 53610d565efSmrg@item RECORD_TYPE 53710d565efSmrgUsed to represent @code{struct} and @code{class} types, as well as 53810d565efSmrgpointers to member functions and similar constructs in other languages. 53910d565efSmrg@code{TYPE_FIELDS} contains the items contained in this type, each of 54010d565efSmrgwhich can be a @code{FIELD_DECL}, @code{VAR_DECL}, @code{CONST_DECL}, or 54110d565efSmrg@code{TYPE_DECL}. You may not make any assumptions about the ordering 54210d565efSmrgof the fields in the type or whether one or more of them overlap. 54310d565efSmrg 54410d565efSmrg@item UNION_TYPE 54510d565efSmrgUsed to represent @code{union} types. Similar to @code{RECORD_TYPE} 54610d565efSmrgexcept that all @code{FIELD_DECL} nodes in @code{TYPE_FIELD} start at 54710d565efSmrgbit position zero. 54810d565efSmrg 54910d565efSmrg@item QUAL_UNION_TYPE 55010d565efSmrgUsed to represent part of a variant record in Ada. Similar to 55110d565efSmrg@code{UNION_TYPE} except that each @code{FIELD_DECL} has a 55210d565efSmrg@code{DECL_QUALIFIER} field, which contains a boolean expression that 55310d565efSmrgindicates whether the field is present in the object. The type will only 55410d565efSmrghave one field, so each field's @code{DECL_QUALIFIER} is only evaluated 55510d565efSmrgif none of the expressions in the previous fields in @code{TYPE_FIELDS} 55610d565efSmrgare nonzero. Normally these expressions will reference a field in the 55710d565efSmrgouter object using a @code{PLACEHOLDER_EXPR}. 55810d565efSmrg 55910d565efSmrg@item LANG_TYPE 56010d565efSmrgThis node is used to represent a language-specific type. The front 56110d565efSmrgend must handle it. 56210d565efSmrg 56310d565efSmrg@item OFFSET_TYPE 56410d565efSmrgThis node is used to represent a pointer-to-data member. For a data 56510d565efSmrgmember @code{X::m} the @code{TYPE_OFFSET_BASETYPE} is @code{X} and the 56610d565efSmrg@code{TREE_TYPE} is the type of @code{m}. 56710d565efSmrg 56810d565efSmrg@end table 56910d565efSmrg 57010d565efSmrgThere are variables whose values represent some of the basic types. 57110d565efSmrgThese include: 57210d565efSmrg@table @code 57310d565efSmrg@item void_type_node 57410d565efSmrgA node for @code{void}. 57510d565efSmrg 57610d565efSmrg@item integer_type_node 57710d565efSmrgA node for @code{int}. 57810d565efSmrg 57910d565efSmrg@item unsigned_type_node. 58010d565efSmrgA node for @code{unsigned int}. 58110d565efSmrg 58210d565efSmrg@item char_type_node. 58310d565efSmrgA node for @code{char}. 58410d565efSmrg@end table 58510d565efSmrg@noindent 58610d565efSmrgIt may sometimes be useful to compare one of these variables with a type 58710d565efSmrgin hand, using @code{same_type_p}. 58810d565efSmrg 58910d565efSmrg@c --------------------------------------------------------------------- 59010d565efSmrg@c Declarations 59110d565efSmrg@c --------------------------------------------------------------------- 59210d565efSmrg 59310d565efSmrg@node Declarations 59410d565efSmrg@section Declarations 59510d565efSmrg@cindex declaration 59610d565efSmrg@cindex variable 59710d565efSmrg@cindex type declaration 59810d565efSmrg@tindex LABEL_DECL 59910d565efSmrg@tindex CONST_DECL 60010d565efSmrg@tindex TYPE_DECL 60110d565efSmrg@tindex VAR_DECL 60210d565efSmrg@tindex PARM_DECL 60310d565efSmrg@tindex DEBUG_EXPR_DECL 60410d565efSmrg@tindex FIELD_DECL 60510d565efSmrg@tindex NAMESPACE_DECL 60610d565efSmrg@tindex RESULT_DECL 60710d565efSmrg@tindex TEMPLATE_DECL 60810d565efSmrg@tindex THUNK_DECL 60910d565efSmrg@findex THUNK_DELTA 61010d565efSmrg@findex DECL_INITIAL 61110d565efSmrg@findex DECL_SIZE 61210d565efSmrg@findex DECL_ALIGN 61310d565efSmrg@findex DECL_EXTERNAL 61410d565efSmrg 61510d565efSmrgThis section covers the various kinds of declarations that appear in the 61610d565efSmrginternal representation, except for declarations of functions 61710d565efSmrg(represented by @code{FUNCTION_DECL} nodes), which are described in 61810d565efSmrg@ref{Functions}. 61910d565efSmrg 62010d565efSmrg@menu 62110d565efSmrg* Working with declarations:: Macros and functions that work on 62210d565efSmrgdeclarations. 62310d565efSmrg* Internal structure:: How declaration nodes are represented. 62410d565efSmrg@end menu 62510d565efSmrg 62610d565efSmrg@node Working with declarations 62710d565efSmrg@subsection Working with declarations 62810d565efSmrg 62910d565efSmrgSome macros can be used with any kind of declaration. These include: 63010d565efSmrg@ftable @code 63110d565efSmrg@item DECL_NAME 63210d565efSmrgThis macro returns an @code{IDENTIFIER_NODE} giving the name of the 63310d565efSmrgentity. 63410d565efSmrg 63510d565efSmrg@item TREE_TYPE 63610d565efSmrgThis macro returns the type of the entity declared. 63710d565efSmrg 63810d565efSmrg@item EXPR_FILENAME 63910d565efSmrgThis macro returns the name of the file in which the entity was 64010d565efSmrgdeclared, as a @code{char*}. For an entity declared implicitly by the 64110d565efSmrgcompiler (like @code{__builtin_memcpy}), this will be the string 64210d565efSmrg@code{"<internal>"}. 64310d565efSmrg 64410d565efSmrg@item EXPR_LINENO 64510d565efSmrgThis macro returns the line number at which the entity was declared, as 64610d565efSmrgan @code{int}. 64710d565efSmrg 64810d565efSmrg@item DECL_ARTIFICIAL 64910d565efSmrgThis predicate holds if the declaration was implicitly generated by the 65010d565efSmrgcompiler. For example, this predicate will hold of an implicitly 65110d565efSmrgdeclared member function, or of the @code{TYPE_DECL} implicitly 65210d565efSmrggenerated for a class type. Recall that in C++ code like: 65310d565efSmrg@smallexample 65410d565efSmrgstruct S @{@}; 65510d565efSmrg@end smallexample 65610d565efSmrg@noindent 65710d565efSmrgis roughly equivalent to C code like: 65810d565efSmrg@smallexample 65910d565efSmrgstruct S @{@}; 66010d565efSmrgtypedef struct S S; 66110d565efSmrg@end smallexample 66210d565efSmrgThe implicitly generated @code{typedef} declaration is represented by a 66310d565efSmrg@code{TYPE_DECL} for which @code{DECL_ARTIFICIAL} holds. 66410d565efSmrg 66510d565efSmrg@end ftable 66610d565efSmrg 66710d565efSmrgThe various kinds of declarations include: 66810d565efSmrg@table @code 66910d565efSmrg@item LABEL_DECL 67010d565efSmrgThese nodes are used to represent labels in function bodies. For more 67110d565efSmrginformation, see @ref{Functions}. These nodes only appear in block 67210d565efSmrgscopes. 67310d565efSmrg 67410d565efSmrg@item CONST_DECL 67510d565efSmrgThese nodes are used to represent enumeration constants. The value of 67610d565efSmrgthe constant is given by @code{DECL_INITIAL} which will be an 67710d565efSmrg@code{INTEGER_CST} with the same type as the @code{TREE_TYPE} of the 67810d565efSmrg@code{CONST_DECL}, i.e., an @code{ENUMERAL_TYPE}. 67910d565efSmrg 68010d565efSmrg@item RESULT_DECL 68110d565efSmrgThese nodes represent the value returned by a function. When a value is 68210d565efSmrgassigned to a @code{RESULT_DECL}, that indicates that the value should 68310d565efSmrgbe returned, via bitwise copy, by the function. You can use 68410d565efSmrg@code{DECL_SIZE} and @code{DECL_ALIGN} on a @code{RESULT_DECL}, just as 68510d565efSmrgwith a @code{VAR_DECL}. 68610d565efSmrg 68710d565efSmrg@item TYPE_DECL 68810d565efSmrgThese nodes represent @code{typedef} declarations. The @code{TREE_TYPE} 68910d565efSmrgis the type declared to have the name given by @code{DECL_NAME}. In 69010d565efSmrgsome cases, there is no associated name. 69110d565efSmrg 69210d565efSmrg@item VAR_DECL 69310d565efSmrgThese nodes represent variables with namespace or block scope, as well 69410d565efSmrgas static data members. The @code{DECL_SIZE} and @code{DECL_ALIGN} are 69510d565efSmrganalogous to @code{TYPE_SIZE} and @code{TYPE_ALIGN}. For a declaration, 69610d565efSmrgyou should always use the @code{DECL_SIZE} and @code{DECL_ALIGN} rather 69710d565efSmrgthan the @code{TYPE_SIZE} and @code{TYPE_ALIGN} given by the 69810d565efSmrg@code{TREE_TYPE}, since special attributes may have been applied to the 69910d565efSmrgvariable to give it a particular size and alignment. You may use the 70010d565efSmrgpredicates @code{DECL_THIS_STATIC} or @code{DECL_THIS_EXTERN} to test 70110d565efSmrgwhether the storage class specifiers @code{static} or @code{extern} were 70210d565efSmrgused to declare a variable. 70310d565efSmrg 70410d565efSmrgIf this variable is initialized (but does not require a constructor), 70510d565efSmrgthe @code{DECL_INITIAL} will be an expression for the initializer. The 70610d565efSmrginitializer should be evaluated, and a bitwise copy into the variable 70710d565efSmrgperformed. If the @code{DECL_INITIAL} is the @code{error_mark_node}, 70810d565efSmrgthere is an initializer, but it is given by an explicit statement later 70910d565efSmrgin the code; no bitwise copy is required. 71010d565efSmrg 71110d565efSmrgGCC provides an extension that allows either automatic variables, or 71210d565efSmrgglobal variables, to be placed in particular registers. This extension 71310d565efSmrgis being used for a particular @code{VAR_DECL} if @code{DECL_REGISTER} 71410d565efSmrgholds for the @code{VAR_DECL}, and if @code{DECL_ASSEMBLER_NAME} is not 71510d565efSmrgequal to @code{DECL_NAME}. In that case, @code{DECL_ASSEMBLER_NAME} is 71610d565efSmrgthe name of the register into which the variable will be placed. 71710d565efSmrg 71810d565efSmrg@item PARM_DECL 71910d565efSmrgUsed to represent a parameter to a function. Treat these nodes 72010d565efSmrgsimilarly to @code{VAR_DECL} nodes. These nodes only appear in the 72110d565efSmrg@code{DECL_ARGUMENTS} for a @code{FUNCTION_DECL}. 72210d565efSmrg 72310d565efSmrgThe @code{DECL_ARG_TYPE} for a @code{PARM_DECL} is the type that will 72410d565efSmrgactually be used when a value is passed to this function. It may be a 72510d565efSmrgwider type than the @code{TREE_TYPE} of the parameter; for example, the 72610d565efSmrgordinary type might be @code{short} while the @code{DECL_ARG_TYPE} is 72710d565efSmrg@code{int}. 72810d565efSmrg 72910d565efSmrg@item DEBUG_EXPR_DECL 73010d565efSmrgUsed to represent an anonymous debug-information temporary created to 73110d565efSmrghold an expression as it is optimized away, so that its value can be 73210d565efSmrgreferenced in debug bind statements. 73310d565efSmrg 73410d565efSmrg@item FIELD_DECL 73510d565efSmrgThese nodes represent non-static data members. The @code{DECL_SIZE} and 73610d565efSmrg@code{DECL_ALIGN} behave as for @code{VAR_DECL} nodes. 73710d565efSmrgThe position of the field within the parent record is specified by a 73810d565efSmrgcombination of three attributes. @code{DECL_FIELD_OFFSET} is the position, 73910d565efSmrgcounting in bytes, of the @code{DECL_OFFSET_ALIGN}-bit sized word containing 74010d565efSmrgthe bit of the field closest to the beginning of the structure. 74110d565efSmrg@code{DECL_FIELD_BIT_OFFSET} is the bit offset of the first bit of the field 74210d565efSmrgwithin this word; this may be nonzero even for fields that are not bit-fields, 74310d565efSmrgsince @code{DECL_OFFSET_ALIGN} may be greater than the natural alignment 74410d565efSmrgof the field's type. 74510d565efSmrg 74610d565efSmrgIf @code{DECL_C_BIT_FIELD} holds, this field is a bit-field. In a bit-field, 74710d565efSmrg@code{DECL_BIT_FIELD_TYPE} also contains the type that was originally 74810d565efSmrgspecified for it, while DECL_TYPE may be a modified type with lesser precision, 74910d565efSmrgaccording to the size of the bit field. 75010d565efSmrg 75110d565efSmrg@item NAMESPACE_DECL 75210d565efSmrgNamespaces provide a name hierarchy for other declarations. They 75310d565efSmrgappear in the @code{DECL_CONTEXT} of other @code{_DECL} nodes. 75410d565efSmrg 75510d565efSmrg@end table 75610d565efSmrg 75710d565efSmrg@node Internal structure 75810d565efSmrg@subsection Internal structure 75910d565efSmrg 76010d565efSmrg@code{DECL} nodes are represented internally as a hierarchy of 76110d565efSmrgstructures. 76210d565efSmrg 76310d565efSmrg@menu 76410d565efSmrg* Current structure hierarchy:: The current DECL node structure 76510d565efSmrghierarchy. 76610d565efSmrg* Adding new DECL node types:: How to add a new DECL node to a 76710d565efSmrgfrontend. 76810d565efSmrg@end menu 76910d565efSmrg 77010d565efSmrg@node Current structure hierarchy 77110d565efSmrg@subsubsection Current structure hierarchy 77210d565efSmrg 77310d565efSmrg@table @code 77410d565efSmrg 77510d565efSmrg@item struct tree_decl_minimal 77610d565efSmrgThis is the minimal structure to inherit from in order for common 77710d565efSmrg@code{DECL} macros to work. The fields it contains are a unique ID, 77810d565efSmrgsource location, context, and name. 77910d565efSmrg 78010d565efSmrg@item struct tree_decl_common 78110d565efSmrgThis structure inherits from @code{struct tree_decl_minimal}. It 78210d565efSmrgcontains fields that most @code{DECL} nodes need, such as a field to 78310d565efSmrgstore alignment, machine mode, size, and attributes. 78410d565efSmrg 78510d565efSmrg@item struct tree_field_decl 78610d565efSmrgThis structure inherits from @code{struct tree_decl_common}. It is 78710d565efSmrgused to represent @code{FIELD_DECL}. 78810d565efSmrg 78910d565efSmrg@item struct tree_label_decl 79010d565efSmrgThis structure inherits from @code{struct tree_decl_common}. It is 79110d565efSmrgused to represent @code{LABEL_DECL}. 79210d565efSmrg 79310d565efSmrg@item struct tree_translation_unit_decl 79410d565efSmrgThis structure inherits from @code{struct tree_decl_common}. It is 79510d565efSmrgused to represent @code{TRANSLATION_UNIT_DECL}. 79610d565efSmrg 79710d565efSmrg@item struct tree_decl_with_rtl 79810d565efSmrgThis structure inherits from @code{struct tree_decl_common}. It 79910d565efSmrgcontains a field to store the low-level RTL associated with a 80010d565efSmrg@code{DECL} node. 80110d565efSmrg 80210d565efSmrg@item struct tree_result_decl 80310d565efSmrgThis structure inherits from @code{struct tree_decl_with_rtl}. It is 80410d565efSmrgused to represent @code{RESULT_DECL}. 80510d565efSmrg 80610d565efSmrg@item struct tree_const_decl 80710d565efSmrgThis structure inherits from @code{struct tree_decl_with_rtl}. It is 80810d565efSmrgused to represent @code{CONST_DECL}. 80910d565efSmrg 81010d565efSmrg@item struct tree_parm_decl 81110d565efSmrgThis structure inherits from @code{struct tree_decl_with_rtl}. It is 81210d565efSmrgused to represent @code{PARM_DECL}. 81310d565efSmrg 81410d565efSmrg@item struct tree_decl_with_vis 81510d565efSmrgThis structure inherits from @code{struct tree_decl_with_rtl}. It 81610d565efSmrgcontains fields necessary to store visibility information, as well as 81710d565efSmrga section name and assembler name. 81810d565efSmrg 81910d565efSmrg@item struct tree_var_decl 82010d565efSmrgThis structure inherits from @code{struct tree_decl_with_vis}. It is 82110d565efSmrgused to represent @code{VAR_DECL}. 82210d565efSmrg 82310d565efSmrg@item struct tree_function_decl 82410d565efSmrgThis structure inherits from @code{struct tree_decl_with_vis}. It is 82510d565efSmrgused to represent @code{FUNCTION_DECL}. 82610d565efSmrg 82710d565efSmrg@end table 82810d565efSmrg@node Adding new DECL node types 82910d565efSmrg@subsubsection Adding new DECL node types 83010d565efSmrg 83110d565efSmrgAdding a new @code{DECL} tree consists of the following steps 83210d565efSmrg 83310d565efSmrg@table @asis 83410d565efSmrg 83510d565efSmrg@item Add a new tree code for the @code{DECL} node 83610d565efSmrgFor language specific @code{DECL} nodes, there is a @file{.def} file 83710d565efSmrgin each frontend directory where the tree code should be added. 83810d565efSmrgFor @code{DECL} nodes that are part of the middle-end, the code should 83910d565efSmrgbe added to @file{tree.def}. 84010d565efSmrg 84110d565efSmrg@item Create a new structure type for the @code{DECL} node 84210d565efSmrgThese structures should inherit from one of the existing structures in 84310d565efSmrgthe language hierarchy by using that structure as the first member. 84410d565efSmrg 84510d565efSmrg@smallexample 84610d565efSmrgstruct tree_foo_decl 84710d565efSmrg@{ 84810d565efSmrg struct tree_decl_with_vis common; 84910d565efSmrg@} 85010d565efSmrg@end smallexample 85110d565efSmrg 85210d565efSmrgWould create a structure name @code{tree_foo_decl} that inherits from 85310d565efSmrg@code{struct tree_decl_with_vis}. 85410d565efSmrg 85510d565efSmrgFor language specific @code{DECL} nodes, this new structure type 85610d565efSmrgshould go in the appropriate @file{.h} file. 85710d565efSmrgFor @code{DECL} nodes that are part of the middle-end, the structure 85810d565efSmrgtype should go in @file{tree.h}. 85910d565efSmrg 86010d565efSmrg@item Add a member to the tree structure enumerator for the node 86110d565efSmrgFor garbage collection and dynamic checking purposes, each @code{DECL} 86210d565efSmrgnode structure type is required to have a unique enumerator value 86310d565efSmrgspecified with it. 86410d565efSmrgFor language specific @code{DECL} nodes, this new enumerator value 86510d565efSmrgshould go in the appropriate @file{.def} file. 86610d565efSmrgFor @code{DECL} nodes that are part of the middle-end, the enumerator 86710d565efSmrgvalues are specified in @file{treestruct.def}. 86810d565efSmrg 86910d565efSmrg@item Update @code{union tree_node} 87010d565efSmrgIn order to make your new structure type usable, it must be added to 87110d565efSmrg@code{union tree_node}. 87210d565efSmrgFor language specific @code{DECL} nodes, a new entry should be added 87310d565efSmrgto the appropriate @file{.h} file of the form 87410d565efSmrg@smallexample 87510d565efSmrg struct tree_foo_decl GTY ((tag ("TS_VAR_DECL"))) foo_decl; 87610d565efSmrg@end smallexample 87710d565efSmrgFor @code{DECL} nodes that are part of the middle-end, the additional 87810d565efSmrgmember goes directly into @code{union tree_node} in @file{tree.h}. 87910d565efSmrg 88010d565efSmrg@item Update dynamic checking info 88110d565efSmrgIn order to be able to check whether accessing a named portion of 88210d565efSmrg@code{union tree_node} is legal, and whether a certain @code{DECL} node 88310d565efSmrgcontains one of the enumerated @code{DECL} node structures in the 88410d565efSmrghierarchy, a simple lookup table is used. 88510d565efSmrgThis lookup table needs to be kept up to date with the tree structure 88610d565efSmrghierarchy, or else checking and containment macros will fail 88710d565efSmrginappropriately. 88810d565efSmrg 88910d565efSmrgFor language specific @code{DECL} nodes, their is an @code{init_ts} 89010d565efSmrgfunction in an appropriate @file{.c} file, which initializes the lookup 89110d565efSmrgtable. 89210d565efSmrgCode setting up the table for new @code{DECL} nodes should be added 89310d565efSmrgthere. 89410d565efSmrgFor each @code{DECL} tree code and enumerator value representing a 89510d565efSmrgmember of the inheritance hierarchy, the table should contain 1 if 89610d565efSmrgthat tree code inherits (directly or indirectly) from that member. 89710d565efSmrgThus, a @code{FOO_DECL} node derived from @code{struct decl_with_rtl}, 89810d565efSmrgand enumerator value @code{TS_FOO_DECL}, would be set up as follows 89910d565efSmrg@smallexample 90010d565efSmrgtree_contains_struct[FOO_DECL][TS_FOO_DECL] = 1; 90110d565efSmrgtree_contains_struct[FOO_DECL][TS_DECL_WRTL] = 1; 90210d565efSmrgtree_contains_struct[FOO_DECL][TS_DECL_COMMON] = 1; 90310d565efSmrgtree_contains_struct[FOO_DECL][TS_DECL_MINIMAL] = 1; 90410d565efSmrg@end smallexample 90510d565efSmrg 90610d565efSmrgFor @code{DECL} nodes that are part of the middle-end, the setup code 90710d565efSmrggoes into @file{tree.c}. 90810d565efSmrg 90910d565efSmrg@item Add macros to access any new fields and flags 91010d565efSmrg 91110d565efSmrgEach added field or flag should have a macro that is used to access 91210d565efSmrgit, that performs appropriate checking to ensure only the right type of 91310d565efSmrg@code{DECL} nodes access the field. 91410d565efSmrg 91510d565efSmrgThese macros generally take the following form 91610d565efSmrg@smallexample 91710d565efSmrg#define FOO_DECL_FIELDNAME(NODE) FOO_DECL_CHECK(NODE)->foo_decl.fieldname 91810d565efSmrg@end smallexample 91910d565efSmrgHowever, if the structure is simply a base class for further 92010d565efSmrgstructures, something like the following should be used 92110d565efSmrg@smallexample 92210d565efSmrg#define BASE_STRUCT_CHECK(T) CONTAINS_STRUCT_CHECK(T, TS_BASE_STRUCT) 92310d565efSmrg#define BASE_STRUCT_FIELDNAME(NODE) \ 92410d565efSmrg (BASE_STRUCT_CHECK(NODE)->base_struct.fieldname 92510d565efSmrg@end smallexample 92610d565efSmrg 92710d565efSmrgReading them from the generated @file{all-tree.def} file (which in 92810d565efSmrgturn includes all the @file{tree.def} files), @file{gencheck.c} is 92910d565efSmrgused during GCC's build to generate the @code{*_CHECK} macros for all 93010d565efSmrgtree codes. 93110d565efSmrg 93210d565efSmrg@end table 93310d565efSmrg 93410d565efSmrg 93510d565efSmrg@c --------------------------------------------------------------------- 93610d565efSmrg@c Attributes 93710d565efSmrg@c --------------------------------------------------------------------- 93810d565efSmrg@node Attributes 93910d565efSmrg@section Attributes in trees 94010d565efSmrg@cindex attributes 94110d565efSmrg 94210d565efSmrgAttributes, as specified using the @code{__attribute__} keyword, are 94310d565efSmrgrepresented internally as a @code{TREE_LIST}. The @code{TREE_PURPOSE} 94410d565efSmrgis the name of the attribute, as an @code{IDENTIFIER_NODE}. The 94510d565efSmrg@code{TREE_VALUE} is a @code{TREE_LIST} of the arguments of the 94610d565efSmrgattribute, if any, or @code{NULL_TREE} if there are no arguments; the 94710d565efSmrgarguments are stored as the @code{TREE_VALUE} of successive entries in 94810d565efSmrgthe list, and may be identifiers or expressions. The @code{TREE_CHAIN} 94910d565efSmrgof the attribute is the next attribute in a list of attributes applying 95010d565efSmrgto the same declaration or type, or @code{NULL_TREE} if there are no 95110d565efSmrgfurther attributes in the list. 95210d565efSmrg 95310d565efSmrgAttributes may be attached to declarations and to types; these 95410d565efSmrgattributes may be accessed with the following macros. All attributes 95510d565efSmrgare stored in this way, and many also cause other changes to the 95610d565efSmrgdeclaration or type or to other internal compiler data structures. 95710d565efSmrg 95810d565efSmrg@deftypefn {Tree Macro} tree DECL_ATTRIBUTES (tree @var{decl}) 95910d565efSmrgThis macro returns the attributes on the declaration @var{decl}. 96010d565efSmrg@end deftypefn 96110d565efSmrg 96210d565efSmrg@deftypefn {Tree Macro} tree TYPE_ATTRIBUTES (tree @var{type}) 96310d565efSmrgThis macro returns the attributes on the type @var{type}. 96410d565efSmrg@end deftypefn 96510d565efSmrg 96610d565efSmrg 96710d565efSmrg@c --------------------------------------------------------------------- 96810d565efSmrg@c Expressions 96910d565efSmrg@c --------------------------------------------------------------------- 97010d565efSmrg 97110d565efSmrg@node Expression trees 97210d565efSmrg@section Expressions 97310d565efSmrg@cindex expression 97410d565efSmrg@findex TREE_TYPE 97510d565efSmrg@findex TREE_OPERAND 97610d565efSmrg 97710d565efSmrgThe internal representation for expressions is for the most part quite 97810d565efSmrgstraightforward. However, there are a few facts that one must bear in 97910d565efSmrgmind. In particular, the expression ``tree'' is actually a directed 98010d565efSmrgacyclic graph. (For example there may be many references to the integer 98110d565efSmrgconstant zero throughout the source program; many of these will be 98210d565efSmrgrepresented by the same expression node.) You should not rely on 98310d565efSmrgcertain kinds of node being shared, nor should you rely on certain kinds of 98410d565efSmrgnodes being unshared. 98510d565efSmrg 98610d565efSmrgThe following macros can be used with all expression nodes: 98710d565efSmrg 98810d565efSmrg@ftable @code 98910d565efSmrg@item TREE_TYPE 99010d565efSmrgReturns the type of the expression. This value may not be precisely the 99110d565efSmrgsame type that would be given the expression in the original program. 99210d565efSmrg@end ftable 99310d565efSmrg 99410d565efSmrgIn what follows, some nodes that one might expect to always have type 99510d565efSmrg@code{bool} are documented to have either integral or boolean type. At 99610d565efSmrgsome point in the future, the C front end may also make use of this same 99710d565efSmrgintermediate representation, and at this point these nodes will 99810d565efSmrgcertainly have integral type. The previous sentence is not meant to 99910d565efSmrgimply that the C++ front end does not or will not give these nodes 100010d565efSmrgintegral type. 100110d565efSmrg 100210d565efSmrgBelow, we list the various kinds of expression nodes. Except where 100310d565efSmrgnoted otherwise, the operands to an expression are accessed using the 100410d565efSmrg@code{TREE_OPERAND} macro. For example, to access the first operand to 100510d565efSmrga binary plus expression @code{expr}, use: 100610d565efSmrg 100710d565efSmrg@smallexample 100810d565efSmrgTREE_OPERAND (expr, 0) 100910d565efSmrg@end smallexample 101010d565efSmrg@noindent 101110d565efSmrg 101210d565efSmrgAs this example indicates, the operands are zero-indexed. 101310d565efSmrg 101410d565efSmrg 101510d565efSmrg@menu 101610d565efSmrg* Constants: Constant expressions. 101710d565efSmrg* Storage References:: 101810d565efSmrg* Unary and Binary Expressions:: 101910d565efSmrg* Vectors:: 102010d565efSmrg@end menu 102110d565efSmrg 102210d565efSmrg@node Constant expressions 102310d565efSmrg@subsection Constant expressions 102410d565efSmrg@tindex INTEGER_CST 102510d565efSmrg@findex tree_int_cst_lt 102610d565efSmrg@findex tree_int_cst_equal 102710d565efSmrg@tindex tree_fits_uhwi_p 102810d565efSmrg@tindex tree_fits_shwi_p 102910d565efSmrg@tindex tree_to_uhwi 103010d565efSmrg@tindex tree_to_shwi 103110d565efSmrg@tindex TREE_INT_CST_NUNITS 103210d565efSmrg@tindex TREE_INT_CST_ELT 103310d565efSmrg@tindex TREE_INT_CST_LOW 103410d565efSmrg@tindex REAL_CST 103510d565efSmrg@tindex FIXED_CST 103610d565efSmrg@tindex COMPLEX_CST 103710d565efSmrg@tindex VECTOR_CST 103810d565efSmrg@tindex STRING_CST 1039c7a68eb7Smrg@tindex POLY_INT_CST 104010d565efSmrg@findex TREE_STRING_LENGTH 104110d565efSmrg@findex TREE_STRING_POINTER 104210d565efSmrg 104310d565efSmrgThe table below begins with constants, moves on to unary expressions, 104410d565efSmrgthen proceeds to binary expressions, and concludes with various other 104510d565efSmrgkinds of expressions: 104610d565efSmrg 104710d565efSmrg@table @code 104810d565efSmrg@item INTEGER_CST 104910d565efSmrgThese nodes represent integer constants. Note that the type of these 105010d565efSmrgconstants is obtained with @code{TREE_TYPE}; they are not always of type 105110d565efSmrg@code{int}. In particular, @code{char} constants are represented with 105210d565efSmrg@code{INTEGER_CST} nodes. The value of the integer constant @code{e} is 105310d565efSmrgrepresented in an array of HOST_WIDE_INT. There are enough elements 105410d565efSmrgin the array to represent the value without taking extra elements for 105510d565efSmrgredundant 0s or -1. The number of elements used to represent @code{e} 105610d565efSmrgis available via @code{TREE_INT_CST_NUNITS}. Element @code{i} can be 105710d565efSmrgextracted by using @code{TREE_INT_CST_ELT (e, i)}. 105810d565efSmrg@code{TREE_INT_CST_LOW} is a shorthand for @code{TREE_INT_CST_ELT (e, 0)}. 105910d565efSmrg 106010d565efSmrgThe functions @code{tree_fits_shwi_p} and @code{tree_fits_uhwi_p} 106110d565efSmrgcan be used to tell if the value is small enough to fit in a 106210d565efSmrgsigned HOST_WIDE_INT or an unsigned HOST_WIDE_INT respectively. 106310d565efSmrgThe value can then be extracted using @code{tree_to_shwi} and 106410d565efSmrg@code{tree_to_uhwi}. 106510d565efSmrg 106610d565efSmrg@item REAL_CST 106710d565efSmrg 106810d565efSmrgFIXME: Talk about how to obtain representations of this constant, do 106910d565efSmrgcomparisons, and so forth. 107010d565efSmrg 107110d565efSmrg@item FIXED_CST 107210d565efSmrg 107310d565efSmrgThese nodes represent fixed-point constants. The type of these constants 107410d565efSmrgis obtained with @code{TREE_TYPE}. @code{TREE_FIXED_CST_PTR} points to 107510d565efSmrga @code{struct fixed_value}; @code{TREE_FIXED_CST} returns the structure 107610d565efSmrgitself. @code{struct fixed_value} contains @code{data} with the size of two 107710d565efSmrg@code{HOST_BITS_PER_WIDE_INT} and @code{mode} as the associated fixed-point 107810d565efSmrgmachine mode for @code{data}. 107910d565efSmrg 108010d565efSmrg@item COMPLEX_CST 108110d565efSmrgThese nodes are used to represent complex number constants, that is a 108210d565efSmrg@code{__complex__} whose parts are constant nodes. The 108310d565efSmrg@code{TREE_REALPART} and @code{TREE_IMAGPART} return the real and the 108410d565efSmrgimaginary parts respectively. 108510d565efSmrg 108610d565efSmrg@item VECTOR_CST 1087c7a68eb7SmrgThese nodes are used to represent vector constants. Each vector 1088c7a68eb7Smrgconstant @var{v} is treated as a specific instance of an arbitrary-length 1089c7a68eb7Smrgsequence that itself contains @samp{VECTOR_CST_NPATTERNS (@var{v})} 1090c7a68eb7Smrginterleaved patterns. Each pattern has the form: 1091c7a68eb7Smrg 1092c7a68eb7Smrg@smallexample 1093c7a68eb7Smrg@{ @var{base0}, @var{base1}, @var{base1} + @var{step}, @var{base1} + @var{step} * 2, @dots{} @} 1094c7a68eb7Smrg@end smallexample 1095c7a68eb7Smrg 1096c7a68eb7SmrgThe first three elements in each pattern are enough to determine the 1097c7a68eb7Smrgvalues of the other elements. However, if all @var{step}s are zero, 1098c7a68eb7Smrgonly the first two elements are needed. If in addition each @var{base1} 1099c7a68eb7Smrgis equal to the corresponding @var{base0}, only the first element in 1100c7a68eb7Smrgeach pattern is needed. The number of encoded elements per pattern 1101c7a68eb7Smrgis given by @samp{VECTOR_CST_NELTS_PER_PATTERN (@var{v})}. 1102c7a68eb7Smrg 1103c7a68eb7SmrgFor example, the constant: 1104c7a68eb7Smrg 1105c7a68eb7Smrg@smallexample 1106c7a68eb7Smrg@{ 0, 1, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8, 18 @} 1107c7a68eb7Smrg@end smallexample 1108c7a68eb7Smrg 1109c7a68eb7Smrgis interpreted as an interleaving of the sequences: 1110c7a68eb7Smrg 1111c7a68eb7Smrg@smallexample 1112c7a68eb7Smrg@{ 0, 2, 3, 4, 5, 6, 7, 8 @} 1113c7a68eb7Smrg@{ 1, 6, 8, 10, 12, 14, 16, 18 @} 1114c7a68eb7Smrg@end smallexample 1115c7a68eb7Smrg 1116c7a68eb7Smrgwhere the sequences are represented by the following patterns: 1117c7a68eb7Smrg 1118c7a68eb7Smrg@smallexample 1119c7a68eb7Smrg@var{base0} == 0, @var{base1} == 2, @var{step} == 1 1120c7a68eb7Smrg@var{base0} == 1, @var{base1} == 6, @var{step} == 2 1121c7a68eb7Smrg@end smallexample 1122c7a68eb7Smrg 1123c7a68eb7SmrgIn this case: 1124c7a68eb7Smrg 1125c7a68eb7Smrg@smallexample 1126c7a68eb7SmrgVECTOR_CST_NPATTERNS (@var{v}) == 2 1127c7a68eb7SmrgVECTOR_CST_NELTS_PER_PATTERN (@var{v}) == 3 1128c7a68eb7Smrg@end smallexample 1129c7a68eb7Smrg 1130c7a68eb7SmrgThe vector is therefore encoded using the first 6 elements 1131c7a68eb7Smrg(@samp{@{ 0, 1, 2, 6, 3, 8 @}}), with the remaining 10 elements 1132c7a68eb7Smrgbeing implicit extensions of them. 1133c7a68eb7Smrg 1134c7a68eb7SmrgSometimes this scheme can create two possible encodings of the same 1135c7a68eb7Smrgvector. For example @{ 0, 1 @} could be seen as two patterns with 1136c7a68eb7Smrgone element each or one pattern with two elements (@var{base0} and 1137c7a68eb7Smrg@var{base1}). The canonical encoding is always the one with the 1138c7a68eb7Smrgfewest patterns or (if both encodings have the same number of 1139c7a68eb7Smrgpetterns) the one with the fewest encoded elements. 1140c7a68eb7Smrg 1141c7a68eb7Smrg@samp{vector_cst_encoding_nelts (@var{v})} gives the total number of 1142c7a68eb7Smrgencoded elements in @var{v}, which is 6 in the example above. 1143c7a68eb7Smrg@code{VECTOR_CST_ENCODED_ELTS (@var{v})} gives a pointer to the elements 1144c7a68eb7Smrgencoded in @var{v} and @code{VECTOR_CST_ENCODED_ELT (@var{v}, @var{i})} 1145c7a68eb7Smrgaccesses the value of encoded element @var{i}. 1146c7a68eb7Smrg 1147c7a68eb7Smrg@samp{VECTOR_CST_DUPLICATE_P (@var{v})} is true if @var{v} simply contains 1148c7a68eb7Smrgrepeated instances of @samp{VECTOR_CST_NPATTERNS (@var{v})} values. This is 1149c7a68eb7Smrga shorthand for testing @samp{VECTOR_CST_NELTS_PER_PATTERN (@var{v}) == 1}. 1150c7a68eb7Smrg 1151c7a68eb7Smrg@samp{VECTOR_CST_STEPPED_P (@var{v})} is true if at least one 1152c7a68eb7Smrgpattern in @var{v} has a nonzero step. This is a shorthand for 1153c7a68eb7Smrgtesting @samp{VECTOR_CST_NELTS_PER_PATTERN (@var{v}) == 3}. 1154c7a68eb7Smrg 1155c7a68eb7SmrgThe utility function @code{vector_cst_elt} gives the value of an 1156c7a68eb7Smrgarbitrary index as a @code{tree}. @code{vector_cst_int_elt} gives 1157c7a68eb7Smrgthe same value as a @code{wide_int}. 115810d565efSmrg 115910d565efSmrg@item STRING_CST 116010d565efSmrgThese nodes represent string-constants. The @code{TREE_STRING_LENGTH} 116110d565efSmrgreturns the length of the string, as an @code{int}. The 116210d565efSmrg@code{TREE_STRING_POINTER} is a @code{char*} containing the string 116310d565efSmrgitself. The string may not be @code{NUL}-terminated, and it may contain 116410d565efSmrgembedded @code{NUL} characters. Therefore, the 116510d565efSmrg@code{TREE_STRING_LENGTH} includes the trailing @code{NUL} if it is 116610d565efSmrgpresent. 116710d565efSmrg 116810d565efSmrgFor wide string constants, the @code{TREE_STRING_LENGTH} is the number 116910d565efSmrgof bytes in the string, and the @code{TREE_STRING_POINTER} 117010d565efSmrgpoints to an array of the bytes of the string, as represented on the 117110d565efSmrgtarget system (that is, as integers in the target endianness). Wide and 117210d565efSmrgnon-wide string constants are distinguished only by the @code{TREE_TYPE} 117310d565efSmrgof the @code{STRING_CST}. 117410d565efSmrg 117510d565efSmrgFIXME: The formats of string constants are not well-defined when the 117610d565efSmrgtarget system bytes are not the same width as host system bytes. 117710d565efSmrg 1178c7a68eb7Smrg@item POLY_INT_CST 1179c7a68eb7SmrgThese nodes represent invariants that depend on some target-specific 1180c7a68eb7Smrgruntime parameters. They consist of @code{NUM_POLY_INT_COEFFS} 1181c7a68eb7Smrgcoefficients, with the first coefficient being the constant term and 1182c7a68eb7Smrgthe others being multipliers that are applied to the runtime parameters. 1183c7a68eb7Smrg 1184c7a68eb7Smrg@code{POLY_INT_CST_ELT (@var{x}, @var{i})} references coefficient number 1185c7a68eb7Smrg@var{i} of @code{POLY_INT_CST} node @var{x}. Each coefficient is an 1186c7a68eb7Smrg@code{INTEGER_CST}. 1187c7a68eb7Smrg 118810d565efSmrg@end table 118910d565efSmrg 119010d565efSmrg@node Storage References 119110d565efSmrg@subsection References to storage 119210d565efSmrg@tindex ADDR_EXPR 119310d565efSmrg@tindex INDIRECT_REF 119410d565efSmrg@tindex MEM_REF 119510d565efSmrg@tindex ARRAY_REF 119610d565efSmrg@tindex ARRAY_RANGE_REF 119710d565efSmrg@tindex TARGET_MEM_REF 119810d565efSmrg@tindex COMPONENT_REF 119910d565efSmrg 120010d565efSmrg@table @code 120110d565efSmrg@item ARRAY_REF 120210d565efSmrgThese nodes represent array accesses. The first operand is the array; 120310d565efSmrgthe second is the index. To calculate the address of the memory 120410d565efSmrgaccessed, you must scale the index by the size of the type of the array 120510d565efSmrgelements. The type of these expressions must be the type of a component of 120610d565efSmrgthe array. The third and fourth operands are used after gimplification 120710d565efSmrgto represent the lower bound and component size but should not be used 120810d565efSmrgdirectly; call @code{array_ref_low_bound} and @code{array_ref_element_size} 120910d565efSmrginstead. 121010d565efSmrg 121110d565efSmrg@item ARRAY_RANGE_REF 121210d565efSmrgThese nodes represent access to a range (or ``slice'') of an array. The 121310d565efSmrgoperands are the same as that for @code{ARRAY_REF} and have the same 121410d565efSmrgmeanings. The type of these expressions must be an array whose component 121510d565efSmrgtype is the same as that of the first operand. The range of that array 121610d565efSmrgtype determines the amount of data these expressions access. 121710d565efSmrg 121810d565efSmrg@item TARGET_MEM_REF 121910d565efSmrgThese nodes represent memory accesses whose address directly map to 122010d565efSmrgan addressing mode of the target architecture. The first argument 122110d565efSmrgis @code{TMR_SYMBOL} and must be a @code{VAR_DECL} of an object with 122210d565efSmrga fixed address. The second argument is @code{TMR_BASE} and the 122310d565efSmrgthird one is @code{TMR_INDEX}. The fourth argument is 122410d565efSmrg@code{TMR_STEP} and must be an @code{INTEGER_CST}. The fifth 122510d565efSmrgargument is @code{TMR_OFFSET} and must be an @code{INTEGER_CST}. 122610d565efSmrgAny of the arguments may be NULL if the appropriate component 122710d565efSmrgdoes not appear in the address. Address of the @code{TARGET_MEM_REF} 122810d565efSmrgis determined in the following way. 122910d565efSmrg 123010d565efSmrg@smallexample 123110d565efSmrg&TMR_SYMBOL + TMR_BASE + TMR_INDEX * TMR_STEP + TMR_OFFSET 123210d565efSmrg@end smallexample 123310d565efSmrg 123410d565efSmrgThe sixth argument is the reference to the original memory access, which 123510d565efSmrgis preserved for the purposes of the RTL alias analysis. The seventh 123610d565efSmrgargument is a tag representing the results of tree level alias analysis. 123710d565efSmrg 123810d565efSmrg@item ADDR_EXPR 123910d565efSmrgThese nodes are used to represent the address of an object. (These 124010d565efSmrgexpressions will always have pointer or reference type.) The operand may 124110d565efSmrgbe another expression, or it may be a declaration. 124210d565efSmrg 124310d565efSmrgAs an extension, GCC allows users to take the address of a label. In 124410d565efSmrgthis case, the operand of the @code{ADDR_EXPR} will be a 124510d565efSmrg@code{LABEL_DECL}. The type of such an expression is @code{void*}. 124610d565efSmrg 124710d565efSmrgIf the object addressed is not an lvalue, a temporary is created, and 124810d565efSmrgthe address of the temporary is used. 124910d565efSmrg 125010d565efSmrg@item INDIRECT_REF 125110d565efSmrgThese nodes are used to represent the object pointed to by a pointer. 125210d565efSmrgThe operand is the pointer being dereferenced; it will always have 125310d565efSmrgpointer or reference type. 125410d565efSmrg 125510d565efSmrg@item MEM_REF 125610d565efSmrgThese nodes are used to represent the object pointed to by a pointer 125710d565efSmrgoffset by a constant. 125810d565efSmrgThe first operand is the pointer being dereferenced; it will always have 125910d565efSmrgpointer or reference type. The second operand is a pointer constant. 126010d565efSmrgIts type is specifying the type to be used for type-based alias analysis. 126110d565efSmrg 126210d565efSmrg@item COMPONENT_REF 126310d565efSmrgThese nodes represent non-static data member accesses. The first 126410d565efSmrgoperand is the object (rather than a pointer to it); the second operand 126510d565efSmrgis the @code{FIELD_DECL} for the data member. The third operand represents 126610d565efSmrgthe byte offset of the field, but should not be used directly; call 126710d565efSmrg@code{component_ref_field_offset} instead. 126810d565efSmrg 126910d565efSmrg 127010d565efSmrg@end table 127110d565efSmrg 127210d565efSmrg@node Unary and Binary Expressions 127310d565efSmrg@subsection Unary and Binary Expressions 127410d565efSmrg@tindex NEGATE_EXPR 127510d565efSmrg@tindex ABS_EXPR 12760fc04c29Smrg@tindex ABSU_EXPR 127710d565efSmrg@tindex BIT_NOT_EXPR 127810d565efSmrg@tindex TRUTH_NOT_EXPR 127910d565efSmrg@tindex PREDECREMENT_EXPR 128010d565efSmrg@tindex PREINCREMENT_EXPR 128110d565efSmrg@tindex POSTDECREMENT_EXPR 128210d565efSmrg@tindex POSTINCREMENT_EXPR 128310d565efSmrg@tindex FIX_TRUNC_EXPR 128410d565efSmrg@tindex FLOAT_EXPR 128510d565efSmrg@tindex COMPLEX_EXPR 128610d565efSmrg@tindex CONJ_EXPR 128710d565efSmrg@tindex REALPART_EXPR 128810d565efSmrg@tindex IMAGPART_EXPR 128910d565efSmrg@tindex NON_LVALUE_EXPR 129010d565efSmrg@tindex NOP_EXPR 129110d565efSmrg@tindex CONVERT_EXPR 129210d565efSmrg@tindex FIXED_CONVERT_EXPR 129310d565efSmrg@tindex THROW_EXPR 129410d565efSmrg@tindex LSHIFT_EXPR 129510d565efSmrg@tindex RSHIFT_EXPR 129610d565efSmrg@tindex BIT_IOR_EXPR 129710d565efSmrg@tindex BIT_XOR_EXPR 129810d565efSmrg@tindex BIT_AND_EXPR 129910d565efSmrg@tindex TRUTH_ANDIF_EXPR 130010d565efSmrg@tindex TRUTH_ORIF_EXPR 130110d565efSmrg@tindex TRUTH_AND_EXPR 130210d565efSmrg@tindex TRUTH_OR_EXPR 130310d565efSmrg@tindex TRUTH_XOR_EXPR 130410d565efSmrg@tindex POINTER_PLUS_EXPR 1305c7a68eb7Smrg@tindex POINTER_DIFF_EXPR 130610d565efSmrg@tindex PLUS_EXPR 130710d565efSmrg@tindex MINUS_EXPR 130810d565efSmrg@tindex MULT_EXPR 130910d565efSmrg@tindex MULT_HIGHPART_EXPR 131010d565efSmrg@tindex RDIV_EXPR 131110d565efSmrg@tindex TRUNC_DIV_EXPR 131210d565efSmrg@tindex FLOOR_DIV_EXPR 131310d565efSmrg@tindex CEIL_DIV_EXPR 131410d565efSmrg@tindex ROUND_DIV_EXPR 131510d565efSmrg@tindex TRUNC_MOD_EXPR 131610d565efSmrg@tindex FLOOR_MOD_EXPR 131710d565efSmrg@tindex CEIL_MOD_EXPR 131810d565efSmrg@tindex ROUND_MOD_EXPR 131910d565efSmrg@tindex EXACT_DIV_EXPR 132010d565efSmrg@tindex LT_EXPR 132110d565efSmrg@tindex LE_EXPR 132210d565efSmrg@tindex GT_EXPR 132310d565efSmrg@tindex GE_EXPR 132410d565efSmrg@tindex EQ_EXPR 132510d565efSmrg@tindex NE_EXPR 132610d565efSmrg@tindex ORDERED_EXPR 132710d565efSmrg@tindex UNORDERED_EXPR 132810d565efSmrg@tindex UNLT_EXPR 132910d565efSmrg@tindex UNLE_EXPR 133010d565efSmrg@tindex UNGT_EXPR 133110d565efSmrg@tindex UNGE_EXPR 133210d565efSmrg@tindex UNEQ_EXPR 133310d565efSmrg@tindex LTGT_EXPR 133410d565efSmrg@tindex MODIFY_EXPR 133510d565efSmrg@tindex INIT_EXPR 133610d565efSmrg@tindex COMPOUND_EXPR 133710d565efSmrg@tindex COND_EXPR 133810d565efSmrg@tindex CALL_EXPR 133910d565efSmrg@tindex STMT_EXPR 134010d565efSmrg@tindex BIND_EXPR 134110d565efSmrg@tindex LOOP_EXPR 134210d565efSmrg@tindex EXIT_EXPR 134310d565efSmrg@tindex CLEANUP_POINT_EXPR 134410d565efSmrg@tindex CONSTRUCTOR 134510d565efSmrg@tindex COMPOUND_LITERAL_EXPR 134610d565efSmrg@tindex SAVE_EXPR 134710d565efSmrg@tindex TARGET_EXPR 134810d565efSmrg@tindex VA_ARG_EXPR 134910d565efSmrg@tindex ANNOTATE_EXPR 135010d565efSmrg 135110d565efSmrg@table @code 135210d565efSmrg@item NEGATE_EXPR 135310d565efSmrgThese nodes represent unary negation of the single operand, for both 135410d565efSmrginteger and floating-point types. The type of negation can be 135510d565efSmrgdetermined by looking at the type of the expression. 135610d565efSmrg 135710d565efSmrgThe behavior of this operation on signed arithmetic overflow is 135810d565efSmrgcontrolled by the @code{flag_wrapv} and @code{flag_trapv} variables. 135910d565efSmrg 136010d565efSmrg@item ABS_EXPR 136110d565efSmrgThese nodes represent the absolute value of the single operand, for 136210d565efSmrgboth integer and floating-point types. This is typically used to 136310d565efSmrgimplement the @code{abs}, @code{labs} and @code{llabs} builtins for 136410d565efSmrginteger types, and the @code{fabs}, @code{fabsf} and @code{fabsl} 136510d565efSmrgbuiltins for floating point types. The type of abs operation can 136610d565efSmrgbe determined by looking at the type of the expression. 136710d565efSmrg 136810d565efSmrgThis node is not used for complex types. To represent the modulus 136910d565efSmrgor complex abs of a complex value, use the @code{BUILT_IN_CABS}, 137010d565efSmrg@code{BUILT_IN_CABSF} or @code{BUILT_IN_CABSL} builtins, as used 137110d565efSmrgto implement the C99 @code{cabs}, @code{cabsf} and @code{cabsl} 137210d565efSmrgbuilt-in functions. 137310d565efSmrg 13740fc04c29Smrg@item ABSU_EXPR 13750fc04c29SmrgThese nodes represent the absolute value of the single operand in 1376*ec02198aSmrgequivalent unsigned type such that @code{ABSU_EXPR} of @code{TYPE_MIN} 1377*ec02198aSmrgis well defined. 13780fc04c29Smrg 137910d565efSmrg@item BIT_NOT_EXPR 138010d565efSmrgThese nodes represent bitwise complement, and will always have integral 138110d565efSmrgtype. The only operand is the value to be complemented. 138210d565efSmrg 138310d565efSmrg@item TRUTH_NOT_EXPR 138410d565efSmrgThese nodes represent logical negation, and will always have integral 138510d565efSmrg(or boolean) type. The operand is the value being negated. The type 138610d565efSmrgof the operand and that of the result are always of @code{BOOLEAN_TYPE} 138710d565efSmrgor @code{INTEGER_TYPE}. 138810d565efSmrg 138910d565efSmrg@item PREDECREMENT_EXPR 139010d565efSmrg@itemx PREINCREMENT_EXPR 139110d565efSmrg@itemx POSTDECREMENT_EXPR 139210d565efSmrg@itemx POSTINCREMENT_EXPR 139310d565efSmrgThese nodes represent increment and decrement expressions. The value of 139410d565efSmrgthe single operand is computed, and the operand incremented or 139510d565efSmrgdecremented. In the case of @code{PREDECREMENT_EXPR} and 139610d565efSmrg@code{PREINCREMENT_EXPR}, the value of the expression is the value 139710d565efSmrgresulting after the increment or decrement; in the case of 139810d565efSmrg@code{POSTDECREMENT_EXPR} and @code{POSTINCREMENT_EXPR} is the value 139910d565efSmrgbefore the increment or decrement occurs. The type of the operand, like 140010d565efSmrgthat of the result, will be either integral, boolean, or floating-point. 140110d565efSmrg 140210d565efSmrg@item FIX_TRUNC_EXPR 140310d565efSmrgThese nodes represent conversion of a floating-point value to an 140410d565efSmrginteger. The single operand will have a floating-point type, while 140510d565efSmrgthe complete expression will have an integral (or boolean) type. The 140610d565efSmrgoperand is rounded towards zero. 140710d565efSmrg 140810d565efSmrg@item FLOAT_EXPR 140910d565efSmrgThese nodes represent conversion of an integral (or boolean) value to a 141010d565efSmrgfloating-point value. The single operand will have integral type, while 141110d565efSmrgthe complete expression will have a floating-point type. 141210d565efSmrg 141310d565efSmrgFIXME: How is the operand supposed to be rounded? Is this dependent on 141410d565efSmrg@option{-mieee}? 141510d565efSmrg 141610d565efSmrg@item COMPLEX_EXPR 141710d565efSmrgThese nodes are used to represent complex numbers constructed from two 141810d565efSmrgexpressions of the same (integer or real) type. The first operand is the 141910d565efSmrgreal part and the second operand is the imaginary part. 142010d565efSmrg 142110d565efSmrg@item CONJ_EXPR 142210d565efSmrgThese nodes represent the conjugate of their operand. 142310d565efSmrg 142410d565efSmrg@item REALPART_EXPR 142510d565efSmrg@itemx IMAGPART_EXPR 142610d565efSmrgThese nodes represent respectively the real and the imaginary parts 142710d565efSmrgof complex numbers (their sole argument). 142810d565efSmrg 142910d565efSmrg@item NON_LVALUE_EXPR 143010d565efSmrgThese nodes indicate that their one and only operand is not an lvalue. 143110d565efSmrgA back end can treat these identically to the single operand. 143210d565efSmrg 143310d565efSmrg@item NOP_EXPR 143410d565efSmrgThese nodes are used to represent conversions that do not require any 143510d565efSmrgcode-generation. For example, conversion of a @code{char*} to an 143610d565efSmrg@code{int*} does not require any code be generated; such a conversion is 143710d565efSmrgrepresented by a @code{NOP_EXPR}. The single operand is the expression 143810d565efSmrgto be converted. The conversion from a pointer to a reference is also 143910d565efSmrgrepresented with a @code{NOP_EXPR}. 144010d565efSmrg 144110d565efSmrg@item CONVERT_EXPR 144210d565efSmrgThese nodes are similar to @code{NOP_EXPR}s, but are used in those 144310d565efSmrgsituations where code may need to be generated. For example, if an 144410d565efSmrg@code{int*} is converted to an @code{int} code may need to be generated 144510d565efSmrgon some platforms. These nodes are never used for C++-specific 144610d565efSmrgconversions, like conversions between pointers to different classes in 144710d565efSmrgan inheritance hierarchy. Any adjustments that need to be made in such 144810d565efSmrgcases are always indicated explicitly. Similarly, a user-defined 144910d565efSmrgconversion is never represented by a @code{CONVERT_EXPR}; instead, the 145010d565efSmrgfunction calls are made explicit. 145110d565efSmrg 145210d565efSmrg@item FIXED_CONVERT_EXPR 145310d565efSmrgThese nodes are used to represent conversions that involve fixed-point 145410d565efSmrgvalues. For example, from a fixed-point value to another fixed-point value, 145510d565efSmrgfrom an integer to a fixed-point value, from a fixed-point value to an 145610d565efSmrginteger, from a floating-point value to a fixed-point value, or from 145710d565efSmrga fixed-point value to a floating-point value. 145810d565efSmrg 145910d565efSmrg@item LSHIFT_EXPR 146010d565efSmrg@itemx RSHIFT_EXPR 146110d565efSmrgThese nodes represent left and right shifts, respectively. The first 146210d565efSmrgoperand is the value to shift; it will always be of integral type. The 146310d565efSmrgsecond operand is an expression for the number of bits by which to 146410d565efSmrgshift. Right shift should be treated as arithmetic, i.e., the 146510d565efSmrghigh-order bits should be zero-filled when the expression has unsigned 146610d565efSmrgtype and filled with the sign bit when the expression has signed type. 146710d565efSmrgNote that the result is undefined if the second operand is larger 146810d565efSmrgthan or equal to the first operand's type size. Unlike most nodes, these 146910d565efSmrgcan have a vector as first operand and a scalar as second operand. 147010d565efSmrg 147110d565efSmrg 147210d565efSmrg@item BIT_IOR_EXPR 147310d565efSmrg@itemx BIT_XOR_EXPR 147410d565efSmrg@itemx BIT_AND_EXPR 147510d565efSmrgThese nodes represent bitwise inclusive or, bitwise exclusive or, and 147610d565efSmrgbitwise and, respectively. Both operands will always have integral 147710d565efSmrgtype. 147810d565efSmrg 147910d565efSmrg@item TRUTH_ANDIF_EXPR 148010d565efSmrg@itemx TRUTH_ORIF_EXPR 148110d565efSmrgThese nodes represent logical ``and'' and logical ``or'', respectively. 148210d565efSmrgThese operators are not strict; i.e., the second operand is evaluated 148310d565efSmrgonly if the value of the expression is not determined by evaluation of 148410d565efSmrgthe first operand. The type of the operands and that of the result are 148510d565efSmrgalways of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}. 148610d565efSmrg 148710d565efSmrg@item TRUTH_AND_EXPR 148810d565efSmrg@itemx TRUTH_OR_EXPR 148910d565efSmrg@itemx TRUTH_XOR_EXPR 149010d565efSmrgThese nodes represent logical and, logical or, and logical exclusive or. 149110d565efSmrgThey are strict; both arguments are always evaluated. There are no 149210d565efSmrgcorresponding operators in C or C++, but the front end will sometimes 149310d565efSmrggenerate these expressions anyhow, if it can tell that strictness does 149410d565efSmrgnot matter. The type of the operands and that of the result are 149510d565efSmrgalways of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}. 149610d565efSmrg 149710d565efSmrg@item POINTER_PLUS_EXPR 149810d565efSmrgThis node represents pointer arithmetic. The first operand is always 149910d565efSmrga pointer/reference type. The second operand is always an unsigned 1500c7a68eb7Smrginteger type compatible with sizetype. This and POINTER_DIFF_EXPR are 1501c7a68eb7Smrgthe only binary arithmetic operators that can operate on pointer types. 1502c7a68eb7Smrg 1503c7a68eb7Smrg@item POINTER_DIFF_EXPR 1504c7a68eb7SmrgThis node represents pointer subtraction. The two operands always 1505c7a68eb7Smrghave pointer/reference type. It returns a signed integer of the same 1506c7a68eb7Smrgprecision as the pointers. The behavior is undefined if the difference 1507c7a68eb7Smrgof the two pointers, seen as infinite precision non-negative integers, 1508c7a68eb7Smrgdoes not fit in the result type. The result does not depend on the 1509c7a68eb7Smrgpointer type, it is not divided by the size of the pointed-to type. 151010d565efSmrg 151110d565efSmrg@item PLUS_EXPR 151210d565efSmrg@itemx MINUS_EXPR 151310d565efSmrg@itemx MULT_EXPR 151410d565efSmrgThese nodes represent various binary arithmetic operations. 151510d565efSmrgRespectively, these operations are addition, subtraction (of the second 151610d565efSmrgoperand from the first) and multiplication. Their operands may have 151710d565efSmrgeither integral or floating type, but there will never be case in which 151810d565efSmrgone operand is of floating type and the other is of integral type. 151910d565efSmrg 152010d565efSmrgThe behavior of these operations on signed arithmetic overflow is 152110d565efSmrgcontrolled by the @code{flag_wrapv} and @code{flag_trapv} variables. 152210d565efSmrg 152310d565efSmrg@item MULT_HIGHPART_EXPR 152410d565efSmrgThis node represents the ``high-part'' of a widening multiplication. 152510d565efSmrgFor an integral type with @var{b} bits of precision, the result is 152610d565efSmrgthe most significant @var{b} bits of the full @math{2@var{b}} product. 152710d565efSmrg 152810d565efSmrg@item RDIV_EXPR 152910d565efSmrgThis node represents a floating point division operation. 153010d565efSmrg 153110d565efSmrg@item TRUNC_DIV_EXPR 153210d565efSmrg@itemx FLOOR_DIV_EXPR 153310d565efSmrg@itemx CEIL_DIV_EXPR 153410d565efSmrg@itemx ROUND_DIV_EXPR 153510d565efSmrgThese nodes represent integer division operations that return an integer 153610d565efSmrgresult. @code{TRUNC_DIV_EXPR} rounds towards zero, @code{FLOOR_DIV_EXPR} 153710d565efSmrgrounds towards negative infinity, @code{CEIL_DIV_EXPR} rounds towards 153810d565efSmrgpositive infinity and @code{ROUND_DIV_EXPR} rounds to the closest integer. 153910d565efSmrgInteger division in C and C++ is truncating, i.e.@: @code{TRUNC_DIV_EXPR}. 154010d565efSmrg 154110d565efSmrgThe behavior of these operations on signed arithmetic overflow, when 154210d565efSmrgdividing the minimum signed integer by minus one, is controlled by the 154310d565efSmrg@code{flag_wrapv} and @code{flag_trapv} variables. 154410d565efSmrg 154510d565efSmrg@item TRUNC_MOD_EXPR 154610d565efSmrg@itemx FLOOR_MOD_EXPR 154710d565efSmrg@itemx CEIL_MOD_EXPR 154810d565efSmrg@itemx ROUND_MOD_EXPR 154910d565efSmrgThese nodes represent the integer remainder or modulus operation. 155010d565efSmrgThe integer modulus of two operands @code{a} and @code{b} is 155110d565efSmrgdefined as @code{a - (a/b)*b} where the division calculated using 155210d565efSmrgthe corresponding division operator. Hence for @code{TRUNC_MOD_EXPR} 155310d565efSmrgthis definition assumes division using truncation towards zero, i.e.@: 155410d565efSmrg@code{TRUNC_DIV_EXPR}. Integer remainder in C and C++ uses truncating 155510d565efSmrgdivision, i.e.@: @code{TRUNC_MOD_EXPR}. 155610d565efSmrg 155710d565efSmrg@item EXACT_DIV_EXPR 155810d565efSmrgThe @code{EXACT_DIV_EXPR} code is used to represent integer divisions where 155910d565efSmrgthe numerator is known to be an exact multiple of the denominator. This 156010d565efSmrgallows the backend to choose between the faster of @code{TRUNC_DIV_EXPR}, 156110d565efSmrg@code{CEIL_DIV_EXPR} and @code{FLOOR_DIV_EXPR} for the current target. 156210d565efSmrg 156310d565efSmrg@item LT_EXPR 156410d565efSmrg@itemx LE_EXPR 156510d565efSmrg@itemx GT_EXPR 156610d565efSmrg@itemx GE_EXPR 1567*ec02198aSmrg@itemx LTGT_EXPR 156810d565efSmrg@itemx EQ_EXPR 156910d565efSmrg@itemx NE_EXPR 1570*ec02198aSmrgThese nodes represent the less than, less than or equal to, greater than, 1571*ec02198aSmrggreater than or equal to, less or greater than, equal, and not equal 1572*ec02198aSmrgcomparison operators. The first and second operands will either be both 1573*ec02198aSmrgof integral type, both of floating type or both of vector type, except for 1574*ec02198aSmrgLTGT_EXPR where they will only be both of floating type. The result type 1575*ec02198aSmrgof these expressions will always be of integral, boolean or signed integral 1576*ec02198aSmrgvector type. These operations return the result type's zero value for false, 1577*ec02198aSmrgthe result type's one value for true, and a vector whose elements are zero 1578*ec02198aSmrg(false) or minus one (true) for vectors. 157910d565efSmrg 158010d565efSmrgFor floating point comparisons, if we honor IEEE NaNs and either operand 158110d565efSmrgis NaN, then @code{NE_EXPR} always returns true and the remaining operators 158210d565efSmrgalways return false. On some targets, comparisons against an IEEE NaN, 1583*ec02198aSmrgother than equality and inequality, may generate a floating-point exception. 158410d565efSmrg 158510d565efSmrg@item ORDERED_EXPR 158610d565efSmrg@itemx UNORDERED_EXPR 158710d565efSmrgThese nodes represent non-trapping ordered and unordered comparison 158810d565efSmrgoperators. These operations take two floating point operands and 158910d565efSmrgdetermine whether they are ordered or unordered relative to each other. 159010d565efSmrgIf either operand is an IEEE NaN, their comparison is defined to be 159110d565efSmrgunordered, otherwise the comparison is defined to be ordered. The 159210d565efSmrgresult type of these expressions will always be of integral or boolean 159310d565efSmrgtype. These operations return the result type's zero value for false, 159410d565efSmrgand the result type's one value for true. 159510d565efSmrg 159610d565efSmrg@item UNLT_EXPR 159710d565efSmrg@itemx UNLE_EXPR 159810d565efSmrg@itemx UNGT_EXPR 159910d565efSmrg@itemx UNGE_EXPR 160010d565efSmrg@itemx UNEQ_EXPR 160110d565efSmrgThese nodes represent the unordered comparison operators. 160210d565efSmrgThese operations take two floating point operands and determine whether 160310d565efSmrgthe operands are unordered or are less than, less than or equal to, 160410d565efSmrggreater than, greater than or equal to, or equal respectively. For 160510d565efSmrgexample, @code{UNLT_EXPR} returns true if either operand is an IEEE 1606*ec02198aSmrgNaN or the first operand is less than the second. All these operations 1607*ec02198aSmrgare guaranteed not to generate a floating point exception. The result 160810d565efSmrgtype of these expressions will always be of integral or boolean type. 160910d565efSmrgThese operations return the result type's zero value for false, 161010d565efSmrgand the result type's one value for true. 161110d565efSmrg 161210d565efSmrg@item MODIFY_EXPR 161310d565efSmrgThese nodes represent assignment. The left-hand side is the first 161410d565efSmrgoperand; the right-hand side is the second operand. The left-hand side 161510d565efSmrgwill be a @code{VAR_DECL}, @code{INDIRECT_REF}, @code{COMPONENT_REF}, or 161610d565efSmrgother lvalue. 161710d565efSmrg 161810d565efSmrgThese nodes are used to represent not only assignment with @samp{=} but 161910d565efSmrgalso compound assignments (like @samp{+=}), by reduction to @samp{=} 162010d565efSmrgassignment. In other words, the representation for @samp{i += 3} looks 162110d565efSmrgjust like that for @samp{i = i + 3}. 162210d565efSmrg 162310d565efSmrg@item INIT_EXPR 162410d565efSmrgThese nodes are just like @code{MODIFY_EXPR}, but are used only when a 162510d565efSmrgvariable is initialized, rather than assigned to subsequently. This 162610d565efSmrgmeans that we can assume that the target of the initialization is not 162710d565efSmrgused in computing its own value; any reference to the lhs in computing 162810d565efSmrgthe rhs is undefined. 162910d565efSmrg 163010d565efSmrg@item COMPOUND_EXPR 163110d565efSmrgThese nodes represent comma-expressions. The first operand is an 163210d565efSmrgexpression whose value is computed and thrown away prior to the 163310d565efSmrgevaluation of the second operand. The value of the entire expression is 163410d565efSmrgthe value of the second operand. 163510d565efSmrg 163610d565efSmrg@item COND_EXPR 163710d565efSmrgThese nodes represent @code{?:} expressions. The first operand 163810d565efSmrgis of boolean or integral type. If it evaluates to a nonzero value, 163910d565efSmrgthe second operand should be evaluated, and returned as the value of the 164010d565efSmrgexpression. Otherwise, the third operand is evaluated, and returned as 164110d565efSmrgthe value of the expression. 164210d565efSmrg 164310d565efSmrgThe second operand must have the same type as the entire expression, 164410d565efSmrgunless it unconditionally throws an exception or calls a noreturn 164510d565efSmrgfunction, in which case it should have void type. The same constraints 164610d565efSmrgapply to the third operand. This allows array bounds checks to be 164710d565efSmrgrepresented conveniently as @code{(i >= 0 && i < 10) ? i : abort()}. 164810d565efSmrg 164910d565efSmrgAs a GNU extension, the C language front-ends allow the second 165010d565efSmrgoperand of the @code{?:} operator may be omitted in the source. 165110d565efSmrgFor example, @code{x ? : 3} is equivalent to @code{x ? x : 3}, 1652c7a68eb7Smrgassuming that @code{x} is an expression without side effects. 165310d565efSmrgIn the tree representation, however, the second operand is always 165410d565efSmrgpresent, possibly protected by @code{SAVE_EXPR} if the first 1655c7a68eb7Smrgargument does cause side effects. 165610d565efSmrg 165710d565efSmrg@item CALL_EXPR 165810d565efSmrgThese nodes are used to represent calls to functions, including 165910d565efSmrgnon-static member functions. @code{CALL_EXPR}s are implemented as 166010d565efSmrgexpression nodes with a variable number of operands. Rather than using 166110d565efSmrg@code{TREE_OPERAND} to extract them, it is preferable to use the 166210d565efSmrgspecialized accessor macros and functions that operate specifically on 166310d565efSmrg@code{CALL_EXPR} nodes. 166410d565efSmrg 166510d565efSmrg@code{CALL_EXPR_FN} returns a pointer to the 166610d565efSmrgfunction to call; it is always an expression whose type is a 166710d565efSmrg@code{POINTER_TYPE}. 166810d565efSmrg 166910d565efSmrgThe number of arguments to the call is returned by @code{call_expr_nargs}, 167010d565efSmrgwhile the arguments themselves can be accessed with the @code{CALL_EXPR_ARG} 167110d565efSmrgmacro. The arguments are zero-indexed and numbered left-to-right. 167210d565efSmrgYou can iterate over the arguments using @code{FOR_EACH_CALL_EXPR_ARG}, as in: 167310d565efSmrg 167410d565efSmrg@smallexample 167510d565efSmrgtree call, arg; 167610d565efSmrgcall_expr_arg_iterator iter; 167710d565efSmrgFOR_EACH_CALL_EXPR_ARG (arg, iter, call) 167810d565efSmrg /* arg is bound to successive arguments of call. */ 167910d565efSmrg @dots{}; 168010d565efSmrg@end smallexample 168110d565efSmrg 168210d565efSmrgFor non-static 168310d565efSmrgmember functions, there will be an operand corresponding to the 168410d565efSmrg@code{this} pointer. There will always be expressions corresponding to 168510d565efSmrgall of the arguments, even if the function is declared with default 168610d565efSmrgarguments and some arguments are not explicitly provided at the call 168710d565efSmrgsites. 168810d565efSmrg 168910d565efSmrg@code{CALL_EXPR}s also have a @code{CALL_EXPR_STATIC_CHAIN} operand that 169010d565efSmrgis used to implement nested functions. This operand is otherwise null. 169110d565efSmrg 169210d565efSmrg@item CLEANUP_POINT_EXPR 169310d565efSmrgThese nodes represent full-expressions. The single operand is an 169410d565efSmrgexpression to evaluate. Any destructor calls engendered by the creation 169510d565efSmrgof temporaries during the evaluation of that expression should be 169610d565efSmrgperformed immediately after the expression is evaluated. 169710d565efSmrg 169810d565efSmrg@item CONSTRUCTOR 169910d565efSmrgThese nodes represent the brace-enclosed initializers for a structure or an 170010d565efSmrgarray. They contain a sequence of component values made out of a vector of 170110d565efSmrgconstructor_elt, which is a (@code{INDEX}, @code{VALUE}) pair. 170210d565efSmrg 170310d565efSmrgIf the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is a @code{RECORD_TYPE}, 170410d565efSmrg@code{UNION_TYPE} or @code{QUAL_UNION_TYPE} then the @code{INDEX} of each 170510d565efSmrgnode in the sequence will be a @code{FIELD_DECL} and the @code{VALUE} will 170610d565efSmrgbe the expression used to initialize that field. 170710d565efSmrg 170810d565efSmrgIf the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is an @code{ARRAY_TYPE}, 170910d565efSmrgthen the @code{INDEX} of each node in the sequence will be an 171010d565efSmrg@code{INTEGER_CST} or a @code{RANGE_EXPR} of two @code{INTEGER_CST}s. 171110d565efSmrgA single @code{INTEGER_CST} indicates which element of the array is being 171210d565efSmrgassigned to. A @code{RANGE_EXPR} indicates an inclusive range of elements 171310d565efSmrgto initialize. In both cases the @code{VALUE} is the corresponding 171410d565efSmrginitializer. It is re-evaluated for each element of a 171510d565efSmrg@code{RANGE_EXPR}. If the @code{INDEX} is @code{NULL_TREE}, then 171610d565efSmrgthe initializer is for the next available array element. 171710d565efSmrg 171810d565efSmrgIn the front end, you should not depend on the fields appearing in any 171910d565efSmrgparticular order. However, in the middle end, fields must appear in 172010d565efSmrgdeclaration order. You should not assume that all fields will be 172110d565efSmrgrepresented. Unrepresented fields will be cleared (zeroed), unless the 172210d565efSmrgCONSTRUCTOR_NO_CLEARING flag is set, in which case their value becomes 172310d565efSmrgundefined. 172410d565efSmrg 172510d565efSmrg@item COMPOUND_LITERAL_EXPR 172610d565efSmrg@findex COMPOUND_LITERAL_EXPR_DECL_EXPR 172710d565efSmrg@findex COMPOUND_LITERAL_EXPR_DECL 172810d565efSmrgThese nodes represent ISO C99 compound literals. The 172910d565efSmrg@code{COMPOUND_LITERAL_EXPR_DECL_EXPR} is a @code{DECL_EXPR} 173010d565efSmrgcontaining an anonymous @code{VAR_DECL} for 173110d565efSmrgthe unnamed object represented by the compound literal; the 173210d565efSmrg@code{DECL_INITIAL} of that @code{VAR_DECL} is a @code{CONSTRUCTOR} 173310d565efSmrgrepresenting the brace-enclosed list of initializers in the compound 173410d565efSmrgliteral. That anonymous @code{VAR_DECL} can also be accessed directly 173510d565efSmrgby the @code{COMPOUND_LITERAL_EXPR_DECL} macro. 173610d565efSmrg 173710d565efSmrg@item SAVE_EXPR 173810d565efSmrg 173910d565efSmrgA @code{SAVE_EXPR} represents an expression (possibly involving 1740c7a68eb7Smrgside effects) that is used more than once. The side effects should 174110d565efSmrgoccur only the first time the expression is evaluated. Subsequent uses 174210d565efSmrgshould just reuse the computed value. The first operand to the 1743c7a68eb7Smrg@code{SAVE_EXPR} is the expression to evaluate. The side effects should 174410d565efSmrgbe executed where the @code{SAVE_EXPR} is first encountered in a 174510d565efSmrgdepth-first preorder traversal of the expression tree. 174610d565efSmrg 174710d565efSmrg@item TARGET_EXPR 174810d565efSmrgA @code{TARGET_EXPR} represents a temporary object. The first operand 174910d565efSmrgis a @code{VAR_DECL} for the temporary variable. The second operand is 175010d565efSmrgthe initializer for the temporary. The initializer is evaluated and, 175110d565efSmrgif non-void, copied (bitwise) into the temporary. If the initializer 175210d565efSmrgis void, that means that it will perform the initialization itself. 175310d565efSmrg 175410d565efSmrgOften, a @code{TARGET_EXPR} occurs on the right-hand side of an 175510d565efSmrgassignment, or as the second operand to a comma-expression which is 175610d565efSmrgitself the right-hand side of an assignment, etc. In this case, we say 175710d565efSmrgthat the @code{TARGET_EXPR} is ``normal''; otherwise, we say it is 175810d565efSmrg``orphaned''. For a normal @code{TARGET_EXPR} the temporary variable 175910d565efSmrgshould be treated as an alias for the left-hand side of the assignment, 176010d565efSmrgrather than as a new temporary variable. 176110d565efSmrg 176210d565efSmrgThe third operand to the @code{TARGET_EXPR}, if present, is a 176310d565efSmrgcleanup-expression (i.e., destructor call) for the temporary. If this 176410d565efSmrgexpression is orphaned, then this expression must be executed when the 176510d565efSmrgstatement containing this expression is complete. These cleanups must 176610d565efSmrgalways be executed in the order opposite to that in which they were 176710d565efSmrgencountered. Note that if a temporary is created on one branch of a 176810d565efSmrgconditional operator (i.e., in the second or third operand to a 176910d565efSmrg@code{COND_EXPR}), the cleanup must be run only if that branch is 177010d565efSmrgactually executed. 177110d565efSmrg 177210d565efSmrg@item VA_ARG_EXPR 177310d565efSmrgThis node is used to implement support for the C/C++ variable argument-list 177410d565efSmrgmechanism. It represents expressions like @code{va_arg (ap, type)}. 177510d565efSmrgIts @code{TREE_TYPE} yields the tree representation for @code{type} and 177610d565efSmrgits sole argument yields the representation for @code{ap}. 177710d565efSmrg 177810d565efSmrg@item ANNOTATE_EXPR 177910d565efSmrgThis node is used to attach markers to an expression. The first operand 178010d565efSmrgis the annotated expression, the second is an @code{INTEGER_CST} with 1781c7a68eb7Smrga value from @code{enum annot_expr_kind}, the third is an @code{INTEGER_CST}. 178210d565efSmrg@end table 178310d565efSmrg 178410d565efSmrg 178510d565efSmrg@node Vectors 178610d565efSmrg@subsection Vectors 1787c7a68eb7Smrg@tindex VEC_DUPLICATE_EXPR 1788c7a68eb7Smrg@tindex VEC_SERIES_EXPR 178910d565efSmrg@tindex VEC_LSHIFT_EXPR 179010d565efSmrg@tindex VEC_RSHIFT_EXPR 179110d565efSmrg@tindex VEC_WIDEN_MULT_HI_EXPR 179210d565efSmrg@tindex VEC_WIDEN_MULT_LO_EXPR 179310d565efSmrg@tindex VEC_UNPACK_HI_EXPR 179410d565efSmrg@tindex VEC_UNPACK_LO_EXPR 179510d565efSmrg@tindex VEC_UNPACK_FLOAT_HI_EXPR 179610d565efSmrg@tindex VEC_UNPACK_FLOAT_LO_EXPR 17970fc04c29Smrg@tindex VEC_UNPACK_FIX_TRUNC_HI_EXPR 17980fc04c29Smrg@tindex VEC_UNPACK_FIX_TRUNC_LO_EXPR 179910d565efSmrg@tindex VEC_PACK_TRUNC_EXPR 180010d565efSmrg@tindex VEC_PACK_SAT_EXPR 180110d565efSmrg@tindex VEC_PACK_FIX_TRUNC_EXPR 18020fc04c29Smrg@tindex VEC_PACK_FLOAT_EXPR 1803c7a68eb7Smrg@tindex VEC_COND_EXPR 180410d565efSmrg@tindex SAD_EXPR 180510d565efSmrg 180610d565efSmrg@table @code 1807c7a68eb7Smrg@item VEC_DUPLICATE_EXPR 1808c7a68eb7SmrgThis node has a single operand and represents a vector in which every 1809c7a68eb7Smrgelement is equal to that operand. 1810c7a68eb7Smrg 1811c7a68eb7Smrg@item VEC_SERIES_EXPR 1812c7a68eb7SmrgThis node represents a vector formed from a scalar base and step, 1813c7a68eb7Smrggiven as the first and second operands respectively. Element @var{i} 1814c7a68eb7Smrgof the result is equal to @samp{@var{base} + @var{i}*@var{step}}. 1815c7a68eb7Smrg 1816c7a68eb7SmrgThis node is restricted to integral types, in order to avoid 1817c7a68eb7Smrgspecifying the rounding behavior for floating-point types. 1818c7a68eb7Smrg 181910d565efSmrg@item VEC_LSHIFT_EXPR 182010d565efSmrg@itemx VEC_RSHIFT_EXPR 182110d565efSmrgThese nodes represent whole vector left and right shifts, respectively. 182210d565efSmrgThe first operand is the vector to shift; it will always be of vector type. 182310d565efSmrgThe second operand is an expression for the number of bits by which to 182410d565efSmrgshift. Note that the result is undefined if the second operand is larger 182510d565efSmrgthan or equal to the first operand's type size. 182610d565efSmrg 182710d565efSmrg@item VEC_WIDEN_MULT_HI_EXPR 182810d565efSmrg@itemx VEC_WIDEN_MULT_LO_EXPR 182910d565efSmrgThese nodes represent widening vector multiplication of the high and low 183010d565efSmrgparts of the two input vectors, respectively. Their operands are vectors 183110d565efSmrgthat contain the same number of elements (@code{N}) of the same integral type. 183210d565efSmrgThe result is a vector that contains half as many elements, of an integral type 183310d565efSmrgwhose size is twice as wide. In the case of @code{VEC_WIDEN_MULT_HI_EXPR} the 183410d565efSmrghigh @code{N/2} elements of the two vector are multiplied to produce the 183510d565efSmrgvector of @code{N/2} products. In the case of @code{VEC_WIDEN_MULT_LO_EXPR} the 183610d565efSmrglow @code{N/2} elements of the two vector are multiplied to produce the 183710d565efSmrgvector of @code{N/2} products. 183810d565efSmrg 183910d565efSmrg@item VEC_UNPACK_HI_EXPR 184010d565efSmrg@itemx VEC_UNPACK_LO_EXPR 184110d565efSmrgThese nodes represent unpacking of the high and low parts of the input vector, 184210d565efSmrgrespectively. The single operand is a vector that contains @code{N} elements 184310d565efSmrgof the same integral or floating point type. The result is a vector 184410d565efSmrgthat contains half as many elements, of an integral or floating point type 184510d565efSmrgwhose size is twice as wide. In the case of @code{VEC_UNPACK_HI_EXPR} the 184610d565efSmrghigh @code{N/2} elements of the vector are extracted and widened (promoted). 184710d565efSmrgIn the case of @code{VEC_UNPACK_LO_EXPR} the low @code{N/2} elements of the 184810d565efSmrgvector are extracted and widened (promoted). 184910d565efSmrg 185010d565efSmrg@item VEC_UNPACK_FLOAT_HI_EXPR 185110d565efSmrg@itemx VEC_UNPACK_FLOAT_LO_EXPR 185210d565efSmrgThese nodes represent unpacking of the high and low parts of the input vector, 185310d565efSmrgwhere the values are converted from fixed point to floating point. The 185410d565efSmrgsingle operand is a vector that contains @code{N} elements of the same 185510d565efSmrgintegral type. The result is a vector that contains half as many elements 185610d565efSmrgof a floating point type whose size is twice as wide. In the case of 18570fc04c29Smrg@code{VEC_UNPACK_FLOAT_HI_EXPR} the high @code{N/2} elements of the vector are 18580fc04c29Smrgextracted, converted and widened. In the case of @code{VEC_UNPACK_FLOAT_LO_EXPR} 185910d565efSmrgthe low @code{N/2} elements of the vector are extracted, converted and widened. 186010d565efSmrg 18610fc04c29Smrg@item VEC_UNPACK_FIX_TRUNC_HI_EXPR 18620fc04c29Smrg@itemx VEC_UNPACK_FIX_TRUNC_LO_EXPR 18630fc04c29SmrgThese nodes represent unpacking of the high and low parts of the input vector, 18640fc04c29Smrgwhere the values are truncated from floating point to fixed point. The 18650fc04c29Smrgsingle operand is a vector that contains @code{N} elements of the same 18660fc04c29Smrgfloating point type. The result is a vector that contains half as many 18670fc04c29Smrgelements of an integral type whose size is twice as wide. In the case of 18680fc04c29Smrg@code{VEC_UNPACK_FIX_TRUNC_HI_EXPR} the high @code{N/2} elements of the 18690fc04c29Smrgvector are extracted and converted with truncation. In the case of 18700fc04c29Smrg@code{VEC_UNPACK_FIX_TRUNC_LO_EXPR} the low @code{N/2} elements of the 18710fc04c29Smrgvector are extracted and converted with truncation. 18720fc04c29Smrg 187310d565efSmrg@item VEC_PACK_TRUNC_EXPR 187410d565efSmrgThis node represents packing of truncated elements of the two input vectors 187510d565efSmrginto the output vector. Input operands are vectors that contain the same 187610d565efSmrgnumber of elements of the same integral or floating point type. The result 187710d565efSmrgis a vector that contains twice as many elements of an integral or floating 187810d565efSmrgpoint type whose size is half as wide. The elements of the two vectors are 187910d565efSmrgdemoted and merged (concatenated) to form the output vector. 188010d565efSmrg 188110d565efSmrg@item VEC_PACK_SAT_EXPR 188210d565efSmrgThis node represents packing of elements of the two input vectors into the 188310d565efSmrgoutput vector using saturation. Input operands are vectors that contain 188410d565efSmrgthe same number of elements of the same integral type. The result is a 188510d565efSmrgvector that contains twice as many elements of an integral type whose size 188610d565efSmrgis half as wide. The elements of the two vectors are demoted and merged 188710d565efSmrg(concatenated) to form the output vector. 188810d565efSmrg 188910d565efSmrg@item VEC_PACK_FIX_TRUNC_EXPR 189010d565efSmrgThis node represents packing of elements of the two input vectors into the 189110d565efSmrgoutput vector, where the values are converted from floating point 189210d565efSmrgto fixed point. Input operands are vectors that contain the same number 189310d565efSmrgof elements of a floating point type. The result is a vector that contains 189410d565efSmrgtwice as many elements of an integral type whose size is half as wide. The 189510d565efSmrgelements of the two vectors are merged (concatenated) to form the output 189610d565efSmrgvector. 189710d565efSmrg 18980fc04c29Smrg@item VEC_PACK_FLOAT_EXPR 18990fc04c29SmrgThis node represents packing of elements of the two input vectors into the 19000fc04c29Smrgoutput vector, where the values are converted from fixed point to floating 19010fc04c29Smrgpoint. Input operands are vectors that contain the same number of elements 19020fc04c29Smrgof an integral type. The result is a vector that contains twice as many 19030fc04c29Smrgelements of floating point type whose size is half as wide. The elements of 19040fc04c29Smrgthe two vectors are merged (concatenated) to form the output vector. 19050fc04c29Smrg 190610d565efSmrg@item VEC_COND_EXPR 190710d565efSmrgThese nodes represent @code{?:} expressions. The three operands must be 190810d565efSmrgvectors of the same size and number of elements. The second and third 190910d565efSmrgoperands must have the same type as the entire expression. The first 191010d565efSmrgoperand is of signed integral vector type. If an element of the first 191110d565efSmrgoperand evaluates to a zero value, the corresponding element of the 191210d565efSmrgresult is taken from the third operand. If it evaluates to a minus one 191310d565efSmrgvalue, it is taken from the second operand. It should never evaluate to 191410d565efSmrgany other value currently, but optimizations should not rely on that 191510d565efSmrgproperty. In contrast with a @code{COND_EXPR}, all operands are always 191610d565efSmrgevaluated. 191710d565efSmrg 191810d565efSmrg@item SAD_EXPR 191910d565efSmrgThis node represents the Sum of Absolute Differences operation. The three 192010d565efSmrgoperands must be vectors of integral types. The first and second operand 192110d565efSmrgmust have the same type. The size of the vector element of the third 192210d565efSmrgoperand must be at lease twice of the size of the vector element of the 192310d565efSmrgfirst and second one. The SAD is calculated between the first and second 192410d565efSmrgoperands, added to the third operand, and returned. 192510d565efSmrg 192610d565efSmrg@end table 192710d565efSmrg 192810d565efSmrg 192910d565efSmrg@c --------------------------------------------------------------------- 193010d565efSmrg@c Statements 193110d565efSmrg@c --------------------------------------------------------------------- 193210d565efSmrg 193310d565efSmrg@node Statements 193410d565efSmrg@section Statements 193510d565efSmrg@cindex Statements 193610d565efSmrg 193710d565efSmrgMost statements in GIMPLE are assignment statements, represented by 193810d565efSmrg@code{GIMPLE_ASSIGN}. No other C expressions can appear at statement level; 193910d565efSmrga reference to a volatile object is converted into a 194010d565efSmrg@code{GIMPLE_ASSIGN}. 194110d565efSmrg 194210d565efSmrgThere are also several varieties of complex statements. 194310d565efSmrg 194410d565efSmrg@menu 194510d565efSmrg* Basic Statements:: 194610d565efSmrg* Blocks:: 194710d565efSmrg* Statement Sequences:: 194810d565efSmrg* Empty Statements:: 194910d565efSmrg* Jumps:: 195010d565efSmrg* Cleanups:: 195110d565efSmrg* OpenMP:: 195210d565efSmrg* OpenACC:: 195310d565efSmrg@end menu 195410d565efSmrg 195510d565efSmrg@node Basic Statements 195610d565efSmrg@subsection Basic Statements 195710d565efSmrg@cindex Basic Statements 195810d565efSmrg 195910d565efSmrg@table @code 196010d565efSmrg@item ASM_EXPR 196110d565efSmrg 196210d565efSmrgUsed to represent an inline assembly statement. For an inline assembly 196310d565efSmrgstatement like: 196410d565efSmrg@smallexample 196510d565efSmrgasm ("mov x, y"); 196610d565efSmrg@end smallexample 196710d565efSmrgThe @code{ASM_STRING} macro will return a @code{STRING_CST} node for 196810d565efSmrg@code{"mov x, y"}. If the original statement made use of the 196910d565efSmrgextended-assembly syntax, then @code{ASM_OUTPUTS}, 197010d565efSmrg@code{ASM_INPUTS}, and @code{ASM_CLOBBERS} will be the outputs, inputs, 197110d565efSmrgand clobbers for the statement, represented as @code{STRING_CST} nodes. 197210d565efSmrgThe extended-assembly syntax looks like: 197310d565efSmrg@smallexample 197410d565efSmrgasm ("fsinx %1,%0" : "=f" (result) : "f" (angle)); 197510d565efSmrg@end smallexample 197610d565efSmrgThe first string is the @code{ASM_STRING}, containing the instruction 197710d565efSmrgtemplate. The next two strings are the output and inputs, respectively; 197810d565efSmrgthis statement has no clobbers. As this example indicates, ``plain'' 197910d565efSmrgassembly statements are merely a special case of extended assembly 198010d565efSmrgstatements; they have no cv-qualifiers, outputs, inputs, or clobbers. 198110d565efSmrgAll of the strings will be @code{NUL}-terminated, and will contain no 198210d565efSmrgembedded @code{NUL}-characters. 198310d565efSmrg 198410d565efSmrgIf the assembly statement is declared @code{volatile}, or if the 198510d565efSmrgstatement was not an extended assembly statement, and is therefore 198610d565efSmrgimplicitly volatile, then the predicate @code{ASM_VOLATILE_P} will hold 198710d565efSmrgof the @code{ASM_EXPR}. 198810d565efSmrg 198910d565efSmrg@item DECL_EXPR 199010d565efSmrg 199110d565efSmrgUsed to represent a local declaration. The @code{DECL_EXPR_DECL} macro 199210d565efSmrgcan be used to obtain the entity declared. This declaration may be a 199310d565efSmrg@code{LABEL_DECL}, indicating that the label declared is a local label. 199410d565efSmrg(As an extension, GCC allows the declaration of labels with scope.) In 199510d565efSmrgC, this declaration may be a @code{FUNCTION_DECL}, indicating the 199610d565efSmrguse of the GCC nested function extension. For more information, 199710d565efSmrg@pxref{Functions}. 199810d565efSmrg 199910d565efSmrg@item LABEL_EXPR 200010d565efSmrg 200110d565efSmrgUsed to represent a label. The @code{LABEL_DECL} declared by this 200210d565efSmrgstatement can be obtained with the @code{LABEL_EXPR_LABEL} macro. The 200310d565efSmrg@code{IDENTIFIER_NODE} giving the name of the label can be obtained from 200410d565efSmrgthe @code{LABEL_DECL} with @code{DECL_NAME}. 200510d565efSmrg 200610d565efSmrg@item GOTO_EXPR 200710d565efSmrg 200810d565efSmrgUsed to represent a @code{goto} statement. The @code{GOTO_DESTINATION} will 200910d565efSmrgusually be a @code{LABEL_DECL}. However, if the ``computed goto'' extension 201010d565efSmrghas been used, the @code{GOTO_DESTINATION} will be an arbitrary expression 201110d565efSmrgindicating the destination. This expression will always have pointer type. 201210d565efSmrg 201310d565efSmrg@item RETURN_EXPR 201410d565efSmrg 201510d565efSmrgUsed to represent a @code{return} statement. Operand 0 represents the 201610d565efSmrgvalue to return. It should either be the @code{RESULT_DECL} for the 201710d565efSmrgcontaining function, or a @code{MODIFY_EXPR} or @code{INIT_EXPR} 201810d565efSmrgsetting the function's @code{RESULT_DECL}. It will be 201910d565efSmrg@code{NULL_TREE} if the statement was just 202010d565efSmrg@smallexample 202110d565efSmrgreturn; 202210d565efSmrg@end smallexample 202310d565efSmrg 202410d565efSmrg@item LOOP_EXPR 202510d565efSmrgThese nodes represent ``infinite'' loops. The @code{LOOP_EXPR_BODY} 202610d565efSmrgrepresents the body of the loop. It should be executed forever, unless 202710d565efSmrgan @code{EXIT_EXPR} is encountered. 202810d565efSmrg 202910d565efSmrg@item EXIT_EXPR 203010d565efSmrgThese nodes represent conditional exits from the nearest enclosing 203110d565efSmrg@code{LOOP_EXPR}. The single operand is the condition; if it is 203210d565efSmrgnonzero, then the loop should be exited. An @code{EXIT_EXPR} will only 203310d565efSmrgappear within a @code{LOOP_EXPR}. 203410d565efSmrg 203510d565efSmrg@item SWITCH_STMT 203610d565efSmrg 203710d565efSmrgUsed to represent a @code{switch} statement. The @code{SWITCH_STMT_COND} 203810d565efSmrgis the expression on which the switch is occurring. See the documentation 203910d565efSmrgfor an @code{IF_STMT} for more information on the representation used 204010d565efSmrgfor the condition. The @code{SWITCH_STMT_BODY} is the body of the switch 204110d565efSmrgstatement. The @code{SWITCH_STMT_TYPE} is the original type of switch 204210d565efSmrgexpression as given in the source, before any compiler conversions. 204310d565efSmrg 204410d565efSmrg@item CASE_LABEL_EXPR 204510d565efSmrg 204610d565efSmrgUse to represent a @code{case} label, range of @code{case} labels, or a 204710d565efSmrg@code{default} label. If @code{CASE_LOW} is @code{NULL_TREE}, then this is a 204810d565efSmrg@code{default} label. Otherwise, if @code{CASE_HIGH} is @code{NULL_TREE}, then 204910d565efSmrgthis is an ordinary @code{case} label. In this case, @code{CASE_LOW} is 205010d565efSmrgan expression giving the value of the label. Both @code{CASE_LOW} and 205110d565efSmrg@code{CASE_HIGH} are @code{INTEGER_CST} nodes. These values will have 205210d565efSmrgthe same type as the condition expression in the switch statement. 205310d565efSmrg 205410d565efSmrgOtherwise, if both @code{CASE_LOW} and @code{CASE_HIGH} are defined, the 205510d565efSmrgstatement is a range of case labels. Such statements originate with the 205610d565efSmrgextension that allows users to write things of the form: 205710d565efSmrg@smallexample 205810d565efSmrgcase 2 ... 5: 205910d565efSmrg@end smallexample 206010d565efSmrgThe first value will be @code{CASE_LOW}, while the second will be 206110d565efSmrg@code{CASE_HIGH}. 206210d565efSmrg 2063c7a68eb7Smrg@item DEBUG_BEGIN_STMT 2064c7a68eb7Smrg 2065c7a68eb7SmrgMarks the beginning of a source statement, for purposes of debug 2066c7a68eb7Smrginformation generation. 2067c7a68eb7Smrg 206810d565efSmrg@end table 206910d565efSmrg 207010d565efSmrg 207110d565efSmrg@node Blocks 207210d565efSmrg@subsection Blocks 207310d565efSmrg@cindex Blocks 207410d565efSmrg 207510d565efSmrgBlock scopes and the variables they declare in GENERIC are 207610d565efSmrgexpressed using the @code{BIND_EXPR} code, which in previous 207710d565efSmrgversions of GCC was primarily used for the C statement-expression 207810d565efSmrgextension. 207910d565efSmrg 208010d565efSmrgVariables in a block are collected into @code{BIND_EXPR_VARS} in 208110d565efSmrgdeclaration order through their @code{TREE_CHAIN} field. Any runtime 208210d565efSmrginitialization is moved out of @code{DECL_INITIAL} and into a 208310d565efSmrgstatement in the controlled block. When gimplifying from C or C++, 208410d565efSmrgthis initialization replaces the @code{DECL_STMT}. These variables 208510d565efSmrgwill never require cleanups. The scope of these variables is just the 208610d565efSmrgbody 208710d565efSmrg 208810d565efSmrgVariable-length arrays (VLAs) complicate this process, as their size 208910d565efSmrgoften refers to variables initialized earlier in the block and their 209010d565efSmrginitialization involves an explicit stack allocation. To handle this, 209110d565efSmrgwe add an indirection and replace them with a pointer to stack space 209210d565efSmrgallocated by means of @code{alloca}. In most cases, we also arrange 209310d565efSmrgfor this space to be reclaimed when the enclosing @code{BIND_EXPR} is 209410d565efSmrgexited, the exception to this being when there is an explicit call to 209510d565efSmrg@code{alloca} in the source code, in which case the stack is left 209610d565efSmrgdepressed on exit of the @code{BIND_EXPR}. 209710d565efSmrg 209810d565efSmrgA C++ program will usually contain more @code{BIND_EXPR}s than 209910d565efSmrgthere are syntactic blocks in the source code, since several C++ 210010d565efSmrgconstructs have implicit scopes associated with them. On the 210110d565efSmrgother hand, although the C++ front end uses pseudo-scopes to 210210d565efSmrghandle cleanups for objects with destructors, these don't 210310d565efSmrgtranslate into the GIMPLE form; multiple declarations at the same 210410d565efSmrglevel use the same @code{BIND_EXPR}. 210510d565efSmrg 210610d565efSmrg@node Statement Sequences 210710d565efSmrg@subsection Statement Sequences 210810d565efSmrg@cindex Statement Sequences 210910d565efSmrg 211010d565efSmrgMultiple statements at the same nesting level are collected into 211110d565efSmrga @code{STATEMENT_LIST}. Statement lists are modified and 211210d565efSmrgtraversed using the interface in @samp{tree-iterator.h}. 211310d565efSmrg 211410d565efSmrg@node Empty Statements 211510d565efSmrg@subsection Empty Statements 211610d565efSmrg@cindex Empty Statements 211710d565efSmrg 211810d565efSmrgWhenever possible, statements with no effect are discarded. But 211910d565efSmrgif they are nested within another construct which cannot be 212010d565efSmrgdiscarded for some reason, they are instead replaced with an 212110d565efSmrgempty statement, generated by @code{build_empty_stmt}. 212210d565efSmrgInitially, all empty statements were shared, after the pattern of 212310d565efSmrgthe Java front end, but this caused a lot of trouble in practice. 212410d565efSmrg 212510d565efSmrgAn empty statement is represented as @code{(void)0}. 212610d565efSmrg 212710d565efSmrg@node Jumps 212810d565efSmrg@subsection Jumps 212910d565efSmrg@cindex Jumps 213010d565efSmrg 213110d565efSmrgOther jumps are expressed by either @code{GOTO_EXPR} or 213210d565efSmrg@code{RETURN_EXPR}. 213310d565efSmrg 213410d565efSmrgThe operand of a @code{GOTO_EXPR} must be either a label or a 213510d565efSmrgvariable containing the address to jump to. 213610d565efSmrg 213710d565efSmrgThe operand of a @code{RETURN_EXPR} is either @code{NULL_TREE}, 213810d565efSmrg@code{RESULT_DECL}, or a @code{MODIFY_EXPR} which sets the return 213910d565efSmrgvalue. It would be nice to move the @code{MODIFY_EXPR} into a 214010d565efSmrgseparate statement, but the special return semantics in 214110d565efSmrg@code{expand_return} make that difficult. It may still happen in 214210d565efSmrgthe future, perhaps by moving most of that logic into 214310d565efSmrg@code{expand_assignment}. 214410d565efSmrg 214510d565efSmrg@node Cleanups 214610d565efSmrg@subsection Cleanups 214710d565efSmrg@cindex Cleanups 214810d565efSmrg 214910d565efSmrgDestructors for local C++ objects and similar dynamic cleanups are 215010d565efSmrgrepresented in GIMPLE by a @code{TRY_FINALLY_EXPR}. 215110d565efSmrg@code{TRY_FINALLY_EXPR} has two operands, both of which are a sequence 215210d565efSmrgof statements to execute. The first sequence is executed. When it 215310d565efSmrgcompletes the second sequence is executed. 215410d565efSmrg 215510d565efSmrgThe first sequence may complete in the following ways: 215610d565efSmrg 215710d565efSmrg@enumerate 215810d565efSmrg 215910d565efSmrg@item Execute the last statement in the sequence and fall off the 216010d565efSmrgend. 216110d565efSmrg 216210d565efSmrg@item Execute a goto statement (@code{GOTO_EXPR}) to an ordinary 216310d565efSmrglabel outside the sequence. 216410d565efSmrg 216510d565efSmrg@item Execute a return statement (@code{RETURN_EXPR}). 216610d565efSmrg 216710d565efSmrg@item Throw an exception. This is currently not explicitly represented in 216810d565efSmrgGIMPLE. 216910d565efSmrg 217010d565efSmrg@end enumerate 217110d565efSmrg 217210d565efSmrgThe second sequence is not executed if the first sequence completes by 217310d565efSmrgcalling @code{setjmp} or @code{exit} or any other function that does 217410d565efSmrgnot return. The second sequence is also not executed if the first 217510d565efSmrgsequence completes via a non-local goto or a computed goto (in general 217610d565efSmrgthe compiler does not know whether such a goto statement exits the 217710d565efSmrgfirst sequence or not, so we assume that it doesn't). 217810d565efSmrg 217910d565efSmrgAfter the second sequence is executed, if it completes normally by 218010d565efSmrgfalling off the end, execution continues wherever the first sequence 218110d565efSmrgwould have continued, by falling off the end, or doing a goto, etc. 218210d565efSmrg 2183*ec02198aSmrgIf the second sequence is an @code{EH_ELSE_EXPR} selector, then the 2184*ec02198aSmrgsequence in its first operand is used when the first sequence completes 2185*ec02198aSmrgnormally, and that in its second operand is used for exceptional 2186*ec02198aSmrgcleanups, i.e., when an exception propagates out of the first sequence. 2187*ec02198aSmrg 218810d565efSmrg@code{TRY_FINALLY_EXPR} complicates the flow graph, since the cleanup 218910d565efSmrgneeds to appear on every edge out of the controlled block; this 219010d565efSmrgreduces the freedom to move code across these edges. Therefore, the 219110d565efSmrgEH lowering pass which runs before most of the optimization passes 219210d565efSmrgeliminates these expressions by explicitly adding the cleanup to each 219310d565efSmrgedge. Rethrowing the exception is represented using @code{RESX_EXPR}. 219410d565efSmrg 219510d565efSmrg@node OpenMP 219610d565efSmrg@subsection OpenMP 219710d565efSmrg@tindex OMP_PARALLEL 219810d565efSmrg@tindex OMP_FOR 219910d565efSmrg@tindex OMP_SECTIONS 220010d565efSmrg@tindex OMP_SINGLE 220110d565efSmrg@tindex OMP_SECTION 220210d565efSmrg@tindex OMP_MASTER 220310d565efSmrg@tindex OMP_ORDERED 220410d565efSmrg@tindex OMP_CRITICAL 220510d565efSmrg@tindex OMP_RETURN 220610d565efSmrg@tindex OMP_CONTINUE 220710d565efSmrg@tindex OMP_ATOMIC 220810d565efSmrg@tindex OMP_CLAUSE 220910d565efSmrg 221010d565efSmrgAll the statements starting with @code{OMP_} represent directives and 22110fc04c29Smrgclauses used by the OpenMP API @w{@uref{https://www.openmp.org}}. 221210d565efSmrg 221310d565efSmrg@table @code 221410d565efSmrg@item OMP_PARALLEL 221510d565efSmrg 221610d565efSmrgRepresents @code{#pragma omp parallel [clause1 @dots{} clauseN]}. It 221710d565efSmrghas four operands: 221810d565efSmrg 221910d565efSmrgOperand @code{OMP_PARALLEL_BODY} is valid while in GENERIC and 222010d565efSmrgHigh GIMPLE forms. It contains the body of code to be executed 222110d565efSmrgby all the threads. During GIMPLE lowering, this operand becomes 222210d565efSmrg@code{NULL} and the body is emitted linearly after 222310d565efSmrg@code{OMP_PARALLEL}. 222410d565efSmrg 222510d565efSmrgOperand @code{OMP_PARALLEL_CLAUSES} is the list of clauses 222610d565efSmrgassociated with the directive. 222710d565efSmrg 222810d565efSmrgOperand @code{OMP_PARALLEL_FN} is created by 222910d565efSmrg@code{pass_lower_omp}, it contains the @code{FUNCTION_DECL} 223010d565efSmrgfor the function that will contain the body of the parallel 223110d565efSmrgregion. 223210d565efSmrg 223310d565efSmrgOperand @code{OMP_PARALLEL_DATA_ARG} is also created by 223410d565efSmrg@code{pass_lower_omp}. If there are shared variables to be 223510d565efSmrgcommunicated to the children threads, this operand will contain 223610d565efSmrgthe @code{VAR_DECL} that contains all the shared values and 223710d565efSmrgvariables. 223810d565efSmrg 223910d565efSmrg@item OMP_FOR 224010d565efSmrg 224110d565efSmrgRepresents @code{#pragma omp for [clause1 @dots{} clauseN]}. It has 224210d565efSmrgsix operands: 224310d565efSmrg 224410d565efSmrgOperand @code{OMP_FOR_BODY} contains the loop body. 224510d565efSmrg 224610d565efSmrgOperand @code{OMP_FOR_CLAUSES} is the list of clauses 224710d565efSmrgassociated with the directive. 224810d565efSmrg 224910d565efSmrgOperand @code{OMP_FOR_INIT} is the loop initialization code of 225010d565efSmrgthe form @code{VAR = N1}. 225110d565efSmrg 225210d565efSmrgOperand @code{OMP_FOR_COND} is the loop conditional expression 225310d565efSmrgof the form @code{VAR @{<,>,<=,>=@} N2}. 225410d565efSmrg 225510d565efSmrgOperand @code{OMP_FOR_INCR} is the loop index increment of the 225610d565efSmrgform @code{VAR @{+=,-=@} INCR}. 225710d565efSmrg 2258c7a68eb7SmrgOperand @code{OMP_FOR_PRE_BODY} contains side effect code from 225910d565efSmrgoperands @code{OMP_FOR_INIT}, @code{OMP_FOR_COND} and 2260c7a68eb7Smrg@code{OMP_FOR_INC}. These side effects are part of the 226110d565efSmrg@code{OMP_FOR} block but must be evaluated before the start of 226210d565efSmrgloop body. 226310d565efSmrg 226410d565efSmrgThe loop index variable @code{VAR} must be a signed integer variable, 226510d565efSmrgwhich is implicitly private to each thread. Bounds 226610d565efSmrg@code{N1} and @code{N2} and the increment expression 226710d565efSmrg@code{INCR} are required to be loop invariant integer 226810d565efSmrgexpressions that are evaluated without any synchronization. The 2269c7a68eb7Smrgevaluation order, frequency of evaluation and side effects are 227010d565efSmrgunspecified by the standard. 227110d565efSmrg 227210d565efSmrg@item OMP_SECTIONS 227310d565efSmrg 227410d565efSmrgRepresents @code{#pragma omp sections [clause1 @dots{} clauseN]}. 227510d565efSmrg 227610d565efSmrgOperand @code{OMP_SECTIONS_BODY} contains the sections body, 227710d565efSmrgwhich in turn contains a set of @code{OMP_SECTION} nodes for 227810d565efSmrgeach of the concurrent sections delimited by @code{#pragma omp 227910d565efSmrgsection}. 228010d565efSmrg 228110d565efSmrgOperand @code{OMP_SECTIONS_CLAUSES} is the list of clauses 228210d565efSmrgassociated with the directive. 228310d565efSmrg 228410d565efSmrg@item OMP_SECTION 228510d565efSmrg 228610d565efSmrgSection delimiter for @code{OMP_SECTIONS}. 228710d565efSmrg 228810d565efSmrg@item OMP_SINGLE 228910d565efSmrg 229010d565efSmrgRepresents @code{#pragma omp single}. 229110d565efSmrg 229210d565efSmrgOperand @code{OMP_SINGLE_BODY} contains the body of code to be 229310d565efSmrgexecuted by a single thread. 229410d565efSmrg 229510d565efSmrgOperand @code{OMP_SINGLE_CLAUSES} is the list of clauses 229610d565efSmrgassociated with the directive. 229710d565efSmrg 229810d565efSmrg@item OMP_MASTER 229910d565efSmrg 230010d565efSmrgRepresents @code{#pragma omp master}. 230110d565efSmrg 230210d565efSmrgOperand @code{OMP_MASTER_BODY} contains the body of code to be 230310d565efSmrgexecuted by the master thread. 230410d565efSmrg 230510d565efSmrg@item OMP_ORDERED 230610d565efSmrg 230710d565efSmrgRepresents @code{#pragma omp ordered}. 230810d565efSmrg 230910d565efSmrgOperand @code{OMP_ORDERED_BODY} contains the body of code to be 231010d565efSmrgexecuted in the sequential order dictated by the loop index 231110d565efSmrgvariable. 231210d565efSmrg 231310d565efSmrg@item OMP_CRITICAL 231410d565efSmrg 231510d565efSmrgRepresents @code{#pragma omp critical [name]}. 231610d565efSmrg 231710d565efSmrgOperand @code{OMP_CRITICAL_BODY} is the critical section. 231810d565efSmrg 231910d565efSmrgOperand @code{OMP_CRITICAL_NAME} is an optional identifier to 232010d565efSmrglabel the critical section. 232110d565efSmrg 232210d565efSmrg@item OMP_RETURN 232310d565efSmrg 232410d565efSmrgThis does not represent any OpenMP directive, it is an artificial 232510d565efSmrgmarker to indicate the end of the body of an OpenMP@. It is used 232610d565efSmrgby the flow graph (@code{tree-cfg.c}) and OpenMP region 232710d565efSmrgbuilding code (@code{omp-low.c}). 232810d565efSmrg 232910d565efSmrg@item OMP_CONTINUE 233010d565efSmrg 233110d565efSmrgSimilarly, this instruction does not represent an OpenMP 233210d565efSmrgdirective, it is used by @code{OMP_FOR} (and similar codes) as well as 233310d565efSmrg@code{OMP_SECTIONS} to mark the place where the code needs to 233410d565efSmrgloop to the next iteration, or the next section, respectively. 233510d565efSmrg 233610d565efSmrgIn some cases, @code{OMP_CONTINUE} is placed right before 233710d565efSmrg@code{OMP_RETURN}. But if there are cleanups that need to 233810d565efSmrgoccur right after the looping body, it will be emitted between 233910d565efSmrg@code{OMP_CONTINUE} and @code{OMP_RETURN}. 234010d565efSmrg 234110d565efSmrg@item OMP_ATOMIC 234210d565efSmrg 234310d565efSmrgRepresents @code{#pragma omp atomic}. 234410d565efSmrg 234510d565efSmrgOperand 0 is the address at which the atomic operation is to be 234610d565efSmrgperformed. 234710d565efSmrg 234810d565efSmrgOperand 1 is the expression to evaluate. The gimplifier tries 234910d565efSmrgthree alternative code generation strategies. Whenever possible, 235010d565efSmrgan atomic update built-in is used. If that fails, a 235110d565efSmrgcompare-and-swap loop is attempted. If that also fails, a 235210d565efSmrgregular critical section around the expression is used. 235310d565efSmrg 235410d565efSmrg@item OMP_CLAUSE 235510d565efSmrg 235610d565efSmrgRepresents clauses associated with one of the @code{OMP_} directives. 235710d565efSmrgClauses are represented by separate subcodes defined in 235810d565efSmrg@file{tree.h}. Clauses codes can be one of: 235910d565efSmrg@code{OMP_CLAUSE_PRIVATE}, @code{OMP_CLAUSE_SHARED}, 236010d565efSmrg@code{OMP_CLAUSE_FIRSTPRIVATE}, 236110d565efSmrg@code{OMP_CLAUSE_LASTPRIVATE}, @code{OMP_CLAUSE_COPYIN}, 236210d565efSmrg@code{OMP_CLAUSE_COPYPRIVATE}, @code{OMP_CLAUSE_IF}, 236310d565efSmrg@code{OMP_CLAUSE_NUM_THREADS}, @code{OMP_CLAUSE_SCHEDULE}, 236410d565efSmrg@code{OMP_CLAUSE_NOWAIT}, @code{OMP_CLAUSE_ORDERED}, 236510d565efSmrg@code{OMP_CLAUSE_DEFAULT}, @code{OMP_CLAUSE_REDUCTION}, 236610d565efSmrg@code{OMP_CLAUSE_COLLAPSE}, @code{OMP_CLAUSE_UNTIED}, 236710d565efSmrg@code{OMP_CLAUSE_FINAL}, and @code{OMP_CLAUSE_MERGEABLE}. Each code 236810d565efSmrgrepresents the corresponding OpenMP clause. 236910d565efSmrg 237010d565efSmrgClauses associated with the same directive are chained together 237110d565efSmrgvia @code{OMP_CLAUSE_CHAIN}. Those clauses that accept a list 237210d565efSmrgof variables are restricted to exactly one, accessed with 237310d565efSmrg@code{OMP_CLAUSE_VAR}. Therefore, multiple variables under the 237410d565efSmrgsame clause @code{C} need to be represented as multiple @code{C} clauses 237510d565efSmrgchained together. This facilitates adding new clauses during 237610d565efSmrgcompilation. 237710d565efSmrg 237810d565efSmrg@end table 237910d565efSmrg 238010d565efSmrg@node OpenACC 238110d565efSmrg@subsection OpenACC 238210d565efSmrg@tindex OACC_CACHE 238310d565efSmrg@tindex OACC_DATA 238410d565efSmrg@tindex OACC_DECLARE 238510d565efSmrg@tindex OACC_ENTER_DATA 238610d565efSmrg@tindex OACC_EXIT_DATA 238710d565efSmrg@tindex OACC_HOST_DATA 238810d565efSmrg@tindex OACC_KERNELS 238910d565efSmrg@tindex OACC_LOOP 239010d565efSmrg@tindex OACC_PARALLEL 2391*ec02198aSmrg@tindex OACC_SERIAL 239210d565efSmrg@tindex OACC_UPDATE 239310d565efSmrg 239410d565efSmrgAll the statements starting with @code{OACC_} represent directives and 2395c7a68eb7Smrgclauses used by the OpenACC API @w{@uref{https://www.openacc.org}}. 239610d565efSmrg 239710d565efSmrg@table @code 239810d565efSmrg@item OACC_CACHE 239910d565efSmrg 240010d565efSmrgRepresents @code{#pragma acc cache (var @dots{})}. 240110d565efSmrg 240210d565efSmrg@item OACC_DATA 240310d565efSmrg 240410d565efSmrgRepresents @code{#pragma acc data [clause1 @dots{} clauseN]}. 240510d565efSmrg 240610d565efSmrg@item OACC_DECLARE 240710d565efSmrg 240810d565efSmrgRepresents @code{#pragma acc declare [clause1 @dots{} clauseN]}. 240910d565efSmrg 241010d565efSmrg@item OACC_ENTER_DATA 241110d565efSmrg 241210d565efSmrgRepresents @code{#pragma acc enter data [clause1 @dots{} clauseN]}. 241310d565efSmrg 241410d565efSmrg@item OACC_EXIT_DATA 241510d565efSmrg 241610d565efSmrgRepresents @code{#pragma acc exit data [clause1 @dots{} clauseN]}. 241710d565efSmrg 241810d565efSmrg@item OACC_HOST_DATA 241910d565efSmrg 242010d565efSmrgRepresents @code{#pragma acc host_data [clause1 @dots{} clauseN]}. 242110d565efSmrg 242210d565efSmrg@item OACC_KERNELS 242310d565efSmrg 242410d565efSmrgRepresents @code{#pragma acc kernels [clause1 @dots{} clauseN]}. 242510d565efSmrg 242610d565efSmrg@item OACC_LOOP 242710d565efSmrg 242810d565efSmrgRepresents @code{#pragma acc loop [clause1 @dots{} clauseN]}. 242910d565efSmrg 243010d565efSmrgSee the description of the @code{OMP_FOR} code. 243110d565efSmrg 243210d565efSmrg@item OACC_PARALLEL 243310d565efSmrg 243410d565efSmrgRepresents @code{#pragma acc parallel [clause1 @dots{} clauseN]}. 243510d565efSmrg 2436*ec02198aSmrg@item OACC_SERIAL 2437*ec02198aSmrg 2438*ec02198aSmrgRepresents @code{#pragma acc serial [clause1 @dots{} clauseN]}. 2439*ec02198aSmrg 244010d565efSmrg@item OACC_UPDATE 244110d565efSmrg 244210d565efSmrgRepresents @code{#pragma acc update [clause1 @dots{} clauseN]}. 244310d565efSmrg 244410d565efSmrg@end table 244510d565efSmrg 244610d565efSmrg@c --------------------------------------------------------------------- 244710d565efSmrg@c Functions 244810d565efSmrg@c --------------------------------------------------------------------- 244910d565efSmrg 245010d565efSmrg@node Functions 245110d565efSmrg@section Functions 245210d565efSmrg@cindex function 245310d565efSmrg@tindex FUNCTION_DECL 245410d565efSmrg 245510d565efSmrgA function is represented by a @code{FUNCTION_DECL} node. It stores 245610d565efSmrgthe basic pieces of the function such as body, parameters, and return 245710d565efSmrgtype as well as information on the surrounding context, visibility, 245810d565efSmrgand linkage. 245910d565efSmrg 246010d565efSmrg@menu 246110d565efSmrg* Function Basics:: Function names, body, and parameters. 246210d565efSmrg* Function Properties:: Context, linkage, etc. 246310d565efSmrg@end menu 246410d565efSmrg 246510d565efSmrg@c --------------------------------------------------------------------- 246610d565efSmrg@c Function Basics 246710d565efSmrg@c --------------------------------------------------------------------- 246810d565efSmrg 246910d565efSmrg@node Function Basics 247010d565efSmrg@subsection Function Basics 247110d565efSmrg@findex DECL_NAME 247210d565efSmrg@findex DECL_ASSEMBLER_NAME 247310d565efSmrg@findex TREE_PUBLIC 247410d565efSmrg@findex DECL_ARTIFICIAL 247510d565efSmrg@findex DECL_FUNCTION_SPECIFIC_TARGET 247610d565efSmrg@findex DECL_FUNCTION_SPECIFIC_OPTIMIZATION 247710d565efSmrg 247810d565efSmrgA function has four core parts: the name, the parameters, the result, 247910d565efSmrgand the body. The following macros and functions access these parts 248010d565efSmrgof a @code{FUNCTION_DECL} as well as other basic features: 248110d565efSmrg@ftable @code 248210d565efSmrg@item DECL_NAME 248310d565efSmrgThis macro returns the unqualified name of the function, as an 248410d565efSmrg@code{IDENTIFIER_NODE}. For an instantiation of a function template, 248510d565efSmrgthe @code{DECL_NAME} is the unqualified name of the template, not 248610d565efSmrgsomething like @code{f<int>}. The value of @code{DECL_NAME} is 248710d565efSmrgundefined when used on a constructor, destructor, overloaded operator, 248810d565efSmrgor type-conversion operator, or any function that is implicitly 248910d565efSmrggenerated by the compiler. See below for macros that can be used to 249010d565efSmrgdistinguish these cases. 249110d565efSmrg 249210d565efSmrg@item DECL_ASSEMBLER_NAME 249310d565efSmrgThis macro returns the mangled name of the function, also an 249410d565efSmrg@code{IDENTIFIER_NODE}. This name does not contain leading underscores 249510d565efSmrgon systems that prefix all identifiers with underscores. The mangled 249610d565efSmrgname is computed in the same way on all platforms; if special processing 249710d565efSmrgis required to deal with the object file format used on a particular 249810d565efSmrgplatform, it is the responsibility of the back end to perform those 249910d565efSmrgmodifications. (Of course, the back end should not modify 250010d565efSmrg@code{DECL_ASSEMBLER_NAME} itself.) 250110d565efSmrg 250210d565efSmrgUsing @code{DECL_ASSEMBLER_NAME} will cause additional memory to be 250310d565efSmrgallocated (for the mangled name of the entity) so it should be used 250410d565efSmrgonly when emitting assembly code. It should not be used within the 250510d565efSmrgoptimizers to determine whether or not two declarations are the same, 250610d565efSmrgeven though some of the existing optimizers do use it in that way. 250710d565efSmrgThese uses will be removed over time. 250810d565efSmrg 250910d565efSmrg@item DECL_ARGUMENTS 251010d565efSmrgThis macro returns the @code{PARM_DECL} for the first argument to the 251110d565efSmrgfunction. Subsequent @code{PARM_DECL} nodes can be obtained by 251210d565efSmrgfollowing the @code{TREE_CHAIN} links. 251310d565efSmrg 251410d565efSmrg@item DECL_RESULT 251510d565efSmrgThis macro returns the @code{RESULT_DECL} for the function. 251610d565efSmrg 251710d565efSmrg@item DECL_SAVED_TREE 251810d565efSmrgThis macro returns the complete body of the function. 251910d565efSmrg 252010d565efSmrg@item TREE_TYPE 252110d565efSmrgThis macro returns the @code{FUNCTION_TYPE} or @code{METHOD_TYPE} for 252210d565efSmrgthe function. 252310d565efSmrg 252410d565efSmrg@item DECL_INITIAL 252510d565efSmrgA function that has a definition in the current translation unit will 252610d565efSmrghave a non-@code{NULL} @code{DECL_INITIAL}. However, back ends should not make 252710d565efSmrguse of the particular value given by @code{DECL_INITIAL}. 252810d565efSmrg 252910d565efSmrgIt should contain a tree of @code{BLOCK} nodes that mirrors the scopes 253010d565efSmrgthat variables are bound in the function. Each block contains a list 253110d565efSmrgof decls declared in a basic block, a pointer to a chain of blocks at 253210d565efSmrgthe next lower scope level, then a pointer to the next block at the 253310d565efSmrgsame level and a backpointer to the parent @code{BLOCK} or 253410d565efSmrg@code{FUNCTION_DECL}. So given a function as follows: 253510d565efSmrg 253610d565efSmrg@smallexample 253710d565efSmrgvoid foo() 253810d565efSmrg@{ 253910d565efSmrg int a; 254010d565efSmrg @{ 254110d565efSmrg int b; 254210d565efSmrg @} 254310d565efSmrg int c; 254410d565efSmrg@} 254510d565efSmrg@end smallexample 254610d565efSmrg 254710d565efSmrgyou would get the following: 254810d565efSmrg 254910d565efSmrg@smallexample 255010d565efSmrgtree foo = FUNCTION_DECL; 255110d565efSmrgtree decl_a = VAR_DECL; 255210d565efSmrgtree decl_b = VAR_DECL; 255310d565efSmrgtree decl_c = VAR_DECL; 255410d565efSmrgtree block_a = BLOCK; 255510d565efSmrgtree block_b = BLOCK; 255610d565efSmrgtree block_c = BLOCK; 255710d565efSmrgBLOCK_VARS(block_a) = decl_a; 255810d565efSmrgBLOCK_SUBBLOCKS(block_a) = block_b; 255910d565efSmrgBLOCK_CHAIN(block_a) = block_c; 256010d565efSmrgBLOCK_SUPERCONTEXT(block_a) = foo; 256110d565efSmrgBLOCK_VARS(block_b) = decl_b; 256210d565efSmrgBLOCK_SUPERCONTEXT(block_b) = block_a; 256310d565efSmrgBLOCK_VARS(block_c) = decl_c; 256410d565efSmrgBLOCK_SUPERCONTEXT(block_c) = foo; 256510d565efSmrgDECL_INITIAL(foo) = block_a; 256610d565efSmrg@end smallexample 256710d565efSmrg 256810d565efSmrg@end ftable 256910d565efSmrg 257010d565efSmrg@c --------------------------------------------------------------------- 257110d565efSmrg@c Function Properties 257210d565efSmrg@c --------------------------------------------------------------------- 257310d565efSmrg 257410d565efSmrg@node Function Properties 257510d565efSmrg@subsection Function Properties 257610d565efSmrg@cindex function properties 257710d565efSmrg@cindex statements 257810d565efSmrg 257910d565efSmrgTo determine the scope of a function, you can use the 258010d565efSmrg@code{DECL_CONTEXT} macro. This macro will return the class 258110d565efSmrg(either a @code{RECORD_TYPE} or a @code{UNION_TYPE}) or namespace (a 258210d565efSmrg@code{NAMESPACE_DECL}) of which the function is a member. For a virtual 258310d565efSmrgfunction, this macro returns the class in which the function was 258410d565efSmrgactually defined, not the base class in which the virtual declaration 258510d565efSmrgoccurred. 258610d565efSmrg 258710d565efSmrgIn C, the @code{DECL_CONTEXT} for a function maybe another function. 258810d565efSmrgThis representation indicates that the GNU nested function extension 258910d565efSmrgis in use. For details on the semantics of nested functions, see the 259010d565efSmrgGCC Manual. The nested function can refer to local variables in its 259110d565efSmrgcontaining function. Such references are not explicitly marked in the 259210d565efSmrgtree structure; back ends must look at the @code{DECL_CONTEXT} for the 259310d565efSmrgreferenced @code{VAR_DECL}. If the @code{DECL_CONTEXT} for the 259410d565efSmrgreferenced @code{VAR_DECL} is not the same as the function currently 259510d565efSmrgbeing processed, and neither @code{DECL_EXTERNAL} nor 259610d565efSmrg@code{TREE_STATIC} hold, then the reference is to a local variable in 259710d565efSmrga containing function, and the back end must take appropriate action. 259810d565efSmrg 259910d565efSmrg@ftable @code 260010d565efSmrg@item DECL_EXTERNAL 260110d565efSmrgThis predicate holds if the function is undefined. 260210d565efSmrg 260310d565efSmrg@item TREE_PUBLIC 260410d565efSmrgThis predicate holds if the function has external linkage. 260510d565efSmrg 260610d565efSmrg@item TREE_STATIC 260710d565efSmrgThis predicate holds if the function has been defined. 260810d565efSmrg 260910d565efSmrg@item TREE_THIS_VOLATILE 261010d565efSmrgThis predicate holds if the function does not return normally. 261110d565efSmrg 261210d565efSmrg@item TREE_READONLY 261310d565efSmrgThis predicate holds if the function can only read its arguments. 261410d565efSmrg 261510d565efSmrg@item DECL_PURE_P 261610d565efSmrgThis predicate holds if the function can only read its arguments, but 261710d565efSmrgmay also read global memory. 261810d565efSmrg 261910d565efSmrg@item DECL_VIRTUAL_P 262010d565efSmrgThis predicate holds if the function is virtual. 262110d565efSmrg 262210d565efSmrg@item DECL_ARTIFICIAL 262310d565efSmrgThis macro holds if the function was implicitly generated by the 262410d565efSmrgcompiler, rather than explicitly declared. In addition to implicitly 262510d565efSmrggenerated class member functions, this macro holds for the special 262610d565efSmrgfunctions created to implement static initialization and destruction, to 262710d565efSmrgcompute run-time type information, and so forth. 262810d565efSmrg 262910d565efSmrg@item DECL_FUNCTION_SPECIFIC_TARGET 263010d565efSmrgThis macro returns a tree node that holds the target options that are 263110d565efSmrgto be used to compile this particular function or @code{NULL_TREE} if 263210d565efSmrgthe function is to be compiled with the target options specified on 263310d565efSmrgthe command line. 263410d565efSmrg 263510d565efSmrg@item DECL_FUNCTION_SPECIFIC_OPTIMIZATION 263610d565efSmrgThis macro returns a tree node that holds the optimization options 263710d565efSmrgthat are to be used to compile this particular function or 263810d565efSmrg@code{NULL_TREE} if the function is to be compiled with the 263910d565efSmrgoptimization options specified on the command line. 264010d565efSmrg 264110d565efSmrg@end ftable 264210d565efSmrg 264310d565efSmrg@c --------------------------------------------------------------------- 264410d565efSmrg@c Language-dependent trees 264510d565efSmrg@c --------------------------------------------------------------------- 264610d565efSmrg 264710d565efSmrg@node Language-dependent trees 264810d565efSmrg@section Language-dependent trees 264910d565efSmrg@cindex language-dependent trees 265010d565efSmrg 265110d565efSmrgFront ends may wish to keep some state associated with various GENERIC 265210d565efSmrgtrees while parsing. To support this, trees provide a set of flags 265310d565efSmrgthat may be used by the front end. They are accessed using 265410d565efSmrg@code{TREE_LANG_FLAG_n} where @samp{n} is currently 0 through 6. 265510d565efSmrg 265610d565efSmrgIf necessary, a front end can use some language-dependent tree 265710d565efSmrgcodes in its GENERIC representation, so long as it provides a 265810d565efSmrghook for converting them to GIMPLE and doesn't expect them to 265910d565efSmrgwork with any (hypothetical) optimizers that run before the 266010d565efSmrgconversion to GIMPLE@. The intermediate representation used while 266110d565efSmrgparsing C and C++ looks very little like GENERIC, but the C and 266210d565efSmrgC++ gimplifier hooks are perfectly happy to take it as input and 266310d565efSmrgspit out GIMPLE@. 266410d565efSmrg 266510d565efSmrg 266610d565efSmrg 266710d565efSmrg@node C and C++ Trees 266810d565efSmrg@section C and C++ Trees 266910d565efSmrg 267010d565efSmrgThis section documents the internal representation used by GCC to 267110d565efSmrgrepresent C and C++ source programs. When presented with a C or C++ 267210d565efSmrgsource program, GCC parses the program, performs semantic analysis 267310d565efSmrg(including the generation of error messages), and then produces the 267410d565efSmrginternal representation described here. This representation contains a 267510d565efSmrgcomplete representation for the entire translation unit provided as 267610d565efSmrginput to the front end. This representation is then typically processed 267710d565efSmrgby a code-generator in order to produce machine code, but could also be 267810d565efSmrgused in the creation of source browsers, intelligent editors, automatic 267910d565efSmrgdocumentation generators, interpreters, and any other programs needing 268010d565efSmrgthe ability to process C or C++ code. 268110d565efSmrg 268210d565efSmrgThis section explains the internal representation. In particular, it 268310d565efSmrgdocuments the internal representation for C and C++ source 268410d565efSmrgconstructs, and the macros, functions, and variables that can be used to 268510d565efSmrgaccess these constructs. The C++ representation is largely a superset 268610d565efSmrgof the representation used in the C front end. There is only one 268710d565efSmrgconstruct used in C that does not appear in the C++ front end and that 268810d565efSmrgis the GNU ``nested function'' extension. Many of the macros documented 268910d565efSmrghere do not apply in C because the corresponding language constructs do 269010d565efSmrgnot appear in C@. 269110d565efSmrg 269210d565efSmrgThe C and C++ front ends generate a mix of GENERIC trees and ones 269310d565efSmrgspecific to C and C++. These language-specific trees are higher-level 269410d565efSmrgconstructs than the ones in GENERIC to make the parser's job easier. 269510d565efSmrgThis section describes those trees that aren't part of GENERIC as well 269610d565efSmrgas aspects of GENERIC trees that are treated in a language-specific 269710d565efSmrgmanner. 269810d565efSmrg 269910d565efSmrgIf you are developing a ``back end'', be it is a code-generator or some 270010d565efSmrgother tool, that uses this representation, you may occasionally find 270110d565efSmrgthat you need to ask questions not easily answered by the functions and 270210d565efSmrgmacros available here. If that situation occurs, it is quite likely 270310d565efSmrgthat GCC already supports the functionality you desire, but that the 270410d565efSmrginterface is simply not documented here. In that case, you should ask 270510d565efSmrgthe GCC maintainers (via mail to @email{gcc@@gcc.gnu.org}) about 270610d565efSmrgdocumenting the functionality you require. Similarly, if you find 270710d565efSmrgyourself writing functions that do not deal directly with your back end, 270810d565efSmrgbut instead might be useful to other people using the GCC front end, you 270910d565efSmrgshould submit your patches for inclusion in GCC@. 271010d565efSmrg 271110d565efSmrg@menu 271210d565efSmrg* Types for C++:: Fundamental and aggregate types. 271310d565efSmrg* Namespaces:: Namespaces. 271410d565efSmrg* Classes:: Classes. 271510d565efSmrg* Functions for C++:: Overloading and accessors for C++. 271610d565efSmrg* Statements for C++:: Statements specific to C and C++. 271710d565efSmrg* C++ Expressions:: From @code{typeid} to @code{throw}. 271810d565efSmrg@end menu 271910d565efSmrg 272010d565efSmrg@node Types for C++ 272110d565efSmrg@subsection Types for C++ 272210d565efSmrg@tindex UNKNOWN_TYPE 272310d565efSmrg@tindex TYPENAME_TYPE 272410d565efSmrg@tindex TYPEOF_TYPE 272510d565efSmrg@findex cp_type_quals 272610d565efSmrg@findex TYPE_UNQUALIFIED 272710d565efSmrg@findex TYPE_QUAL_CONST 272810d565efSmrg@findex TYPE_QUAL_VOLATILE 272910d565efSmrg@findex TYPE_QUAL_RESTRICT 273010d565efSmrg@findex TYPE_MAIN_VARIANT 273110d565efSmrg@cindex qualified type 273210d565efSmrg@findex TYPE_SIZE 273310d565efSmrg@findex TYPE_ALIGN 273410d565efSmrg@findex TYPE_PRECISION 273510d565efSmrg@findex TYPE_ARG_TYPES 273610d565efSmrg@findex TYPE_METHOD_BASETYPE 273710d565efSmrg@findex TYPE_PTRDATAMEM_P 273810d565efSmrg@findex TYPE_OFFSET_BASETYPE 273910d565efSmrg@findex TREE_TYPE 274010d565efSmrg@findex TYPE_CONTEXT 274110d565efSmrg@findex TYPE_NAME 274210d565efSmrg@findex TYPENAME_TYPE_FULLNAME 274310d565efSmrg@findex TYPE_FIELDS 274410d565efSmrg@findex TYPE_PTROBV_P 274510d565efSmrg 274610d565efSmrgIn C++, an array type is not qualified; rather the type of the array 274710d565efSmrgelements is qualified. This situation is reflected in the intermediate 274810d565efSmrgrepresentation. The macros described here will always examine the 274910d565efSmrgqualification of the underlying element type when applied to an array 275010d565efSmrgtype. (If the element type is itself an array, then the recursion 275110d565efSmrgcontinues until a non-array type is found, and the qualification of this 275210d565efSmrgtype is examined.) So, for example, @code{CP_TYPE_CONST_P} will hold of 275310d565efSmrgthe type @code{const int ()[7]}, denoting an array of seven @code{int}s. 275410d565efSmrg 275510d565efSmrgThe following functions and macros deal with cv-qualification of types: 275610d565efSmrg@ftable @code 275710d565efSmrg@item cp_type_quals 275810d565efSmrgThis function returns the set of type qualifiers applied to this type. 275910d565efSmrgThis value is @code{TYPE_UNQUALIFIED} if no qualifiers have been 276010d565efSmrgapplied. The @code{TYPE_QUAL_CONST} bit is set if the type is 276110d565efSmrg@code{const}-qualified. The @code{TYPE_QUAL_VOLATILE} bit is set if the 276210d565efSmrgtype is @code{volatile}-qualified. The @code{TYPE_QUAL_RESTRICT} bit is 276310d565efSmrgset if the type is @code{restrict}-qualified. 276410d565efSmrg 276510d565efSmrg@item CP_TYPE_CONST_P 276610d565efSmrgThis macro holds if the type is @code{const}-qualified. 276710d565efSmrg 276810d565efSmrg@item CP_TYPE_VOLATILE_P 276910d565efSmrgThis macro holds if the type is @code{volatile}-qualified. 277010d565efSmrg 277110d565efSmrg@item CP_TYPE_RESTRICT_P 277210d565efSmrgThis macro holds if the type is @code{restrict}-qualified. 277310d565efSmrg 277410d565efSmrg@item CP_TYPE_CONST_NON_VOLATILE_P 277510d565efSmrgThis predicate holds for a type that is @code{const}-qualified, but 277610d565efSmrg@emph{not} @code{volatile}-qualified; other cv-qualifiers are ignored as 277710d565efSmrgwell: only the @code{const}-ness is tested. 277810d565efSmrg 277910d565efSmrg@end ftable 278010d565efSmrg 278110d565efSmrgA few other macros and functions are usable with all types: 278210d565efSmrg@ftable @code 278310d565efSmrg@item TYPE_SIZE 278410d565efSmrgThe number of bits required to represent the type, represented as an 278510d565efSmrg@code{INTEGER_CST}. For an incomplete type, @code{TYPE_SIZE} will be 278610d565efSmrg@code{NULL_TREE}. 278710d565efSmrg 278810d565efSmrg@item TYPE_ALIGN 278910d565efSmrgThe alignment of the type, in bits, represented as an @code{int}. 279010d565efSmrg 279110d565efSmrg@item TYPE_NAME 279210d565efSmrgThis macro returns a declaration (in the form of a @code{TYPE_DECL}) for 279310d565efSmrgthe type. (Note this macro does @emph{not} return an 279410d565efSmrg@code{IDENTIFIER_NODE}, as you might expect, given its name!) You can 279510d565efSmrglook at the @code{DECL_NAME} of the @code{TYPE_DECL} to obtain the 279610d565efSmrgactual name of the type. The @code{TYPE_NAME} will be @code{NULL_TREE} 279710d565efSmrgfor a type that is not a built-in type, the result of a typedef, or a 279810d565efSmrgnamed class type. 279910d565efSmrg 280010d565efSmrg@item CP_INTEGRAL_TYPE 280110d565efSmrgThis predicate holds if the type is an integral type. Notice that in 280210d565efSmrgC++, enumerations are @emph{not} integral types. 280310d565efSmrg 280410d565efSmrg@item ARITHMETIC_TYPE_P 280510d565efSmrgThis predicate holds if the type is an integral type (in the C++ sense) 280610d565efSmrgor a floating point type. 280710d565efSmrg 280810d565efSmrg@item CLASS_TYPE_P 280910d565efSmrgThis predicate holds for a class-type. 281010d565efSmrg 281110d565efSmrg@item TYPE_BUILT_IN 281210d565efSmrgThis predicate holds for a built-in type. 281310d565efSmrg 281410d565efSmrg@item TYPE_PTRDATAMEM_P 281510d565efSmrgThis predicate holds if the type is a pointer to data member. 281610d565efSmrg 281710d565efSmrg@item TYPE_PTR_P 281810d565efSmrgThis predicate holds if the type is a pointer type, and the pointee is 281910d565efSmrgnot a data member. 282010d565efSmrg 282110d565efSmrg@item TYPE_PTRFN_P 282210d565efSmrgThis predicate holds for a pointer to function type. 282310d565efSmrg 282410d565efSmrg@item TYPE_PTROB_P 282510d565efSmrgThis predicate holds for a pointer to object type. Note however that it 282610d565efSmrgdoes not hold for the generic pointer to object type @code{void *}. You 282710d565efSmrgmay use @code{TYPE_PTROBV_P} to test for a pointer to object type as 282810d565efSmrgwell as @code{void *}. 282910d565efSmrg 283010d565efSmrg@end ftable 283110d565efSmrg 283210d565efSmrgThe table below describes types specific to C and C++ as well as 283310d565efSmrglanguage-dependent info about GENERIC types. 283410d565efSmrg 283510d565efSmrg@table @code 283610d565efSmrg 283710d565efSmrg@item POINTER_TYPE 283810d565efSmrgUsed to represent pointer types, and pointer to data member types. If 283910d565efSmrg@code{TREE_TYPE} 284010d565efSmrgis a pointer to data member type, then @code{TYPE_PTRDATAMEM_P} will hold. 284110d565efSmrgFor a pointer to data member type of the form @samp{T X::*}, 284210d565efSmrg@code{TYPE_PTRMEM_CLASS_TYPE} will be the type @code{X}, while 284310d565efSmrg@code{TYPE_PTRMEM_POINTED_TO_TYPE} will be the type @code{T}. 284410d565efSmrg 284510d565efSmrg@item RECORD_TYPE 284610d565efSmrgUsed to represent @code{struct} and @code{class} types in C and C++. If 284710d565efSmrg@code{TYPE_PTRMEMFUNC_P} holds, then this type is a pointer-to-member 284810d565efSmrgtype. In that case, the @code{TYPE_PTRMEMFUNC_FN_TYPE} is a 284910d565efSmrg@code{POINTER_TYPE} pointing to a @code{METHOD_TYPE}. The 285010d565efSmrg@code{METHOD_TYPE} is the type of a function pointed to by the 285110d565efSmrgpointer-to-member function. If @code{TYPE_PTRMEMFUNC_P} does not hold, 285210d565efSmrgthis type is a class type. For more information, @pxref{Classes}. 285310d565efSmrg 285410d565efSmrg@item UNKNOWN_TYPE 285510d565efSmrgThis node is used to represent a type the knowledge of which is 285610d565efSmrginsufficient for a sound processing. 285710d565efSmrg 285810d565efSmrg@item TYPENAME_TYPE 285910d565efSmrgUsed to represent a construct of the form @code{typename T::A}. The 286010d565efSmrg@code{TYPE_CONTEXT} is @code{T}; the @code{TYPE_NAME} is an 286110d565efSmrg@code{IDENTIFIER_NODE} for @code{A}. If the type is specified via a 286210d565efSmrgtemplate-id, then @code{TYPENAME_TYPE_FULLNAME} yields a 286310d565efSmrg@code{TEMPLATE_ID_EXPR}. The @code{TREE_TYPE} is non-@code{NULL} if the 286410d565efSmrgnode is implicitly generated in support for the implicit typename 286510d565efSmrgextension; in which case the @code{TREE_TYPE} is a type node for the 286610d565efSmrgbase-class. 286710d565efSmrg 286810d565efSmrg@item TYPEOF_TYPE 286910d565efSmrgUsed to represent the @code{__typeof__} extension. The 287010d565efSmrg@code{TYPE_FIELDS} is the expression the type of which is being 287110d565efSmrgrepresented. 287210d565efSmrg 287310d565efSmrg@end table 287410d565efSmrg 287510d565efSmrg 287610d565efSmrg@c --------------------------------------------------------------------- 287710d565efSmrg@c Namespaces 287810d565efSmrg@c --------------------------------------------------------------------- 287910d565efSmrg 288010d565efSmrg@node Namespaces 288110d565efSmrg@subsection Namespaces 288210d565efSmrg@cindex namespace, scope 288310d565efSmrg@tindex NAMESPACE_DECL 288410d565efSmrg 288510d565efSmrgThe root of the entire intermediate representation is the variable 288610d565efSmrg@code{global_namespace}. This is the namespace specified with @code{::} 288710d565efSmrgin C++ source code. All other namespaces, types, variables, functions, 288810d565efSmrgand so forth can be found starting with this namespace. 288910d565efSmrg 289010d565efSmrgHowever, except for the fact that it is distinguished as the root of the 289110d565efSmrgrepresentation, the global namespace is no different from any other 289210d565efSmrgnamespace. Thus, in what follows, we describe namespaces generally, 289310d565efSmrgrather than the global namespace in particular. 289410d565efSmrg 289510d565efSmrgA namespace is represented by a @code{NAMESPACE_DECL} node. 289610d565efSmrg 289710d565efSmrgThe following macros and functions can be used on a @code{NAMESPACE_DECL}: 289810d565efSmrg 289910d565efSmrg@ftable @code 290010d565efSmrg@item DECL_NAME 290110d565efSmrgThis macro is used to obtain the @code{IDENTIFIER_NODE} corresponding to 290210d565efSmrgthe unqualified name of the name of the namespace (@pxref{Identifiers}). 290310d565efSmrgThe name of the global namespace is @samp{::}, even though in C++ the 290410d565efSmrgglobal namespace is unnamed. However, you should use comparison with 290510d565efSmrg@code{global_namespace}, rather than @code{DECL_NAME} to determine 290610d565efSmrgwhether or not a namespace is the global one. An unnamed namespace 290710d565efSmrgwill have a @code{DECL_NAME} equal to @code{anonymous_namespace_name}. 290810d565efSmrgWithin a single translation unit, all unnamed namespaces will have the 290910d565efSmrgsame name. 291010d565efSmrg 291110d565efSmrg@item DECL_CONTEXT 291210d565efSmrgThis macro returns the enclosing namespace. The @code{DECL_CONTEXT} for 291310d565efSmrgthe @code{global_namespace} is @code{NULL_TREE}. 291410d565efSmrg 291510d565efSmrg@item DECL_NAMESPACE_ALIAS 291610d565efSmrgIf this declaration is for a namespace alias, then 291710d565efSmrg@code{DECL_NAMESPACE_ALIAS} is the namespace for which this one is an 291810d565efSmrgalias. 291910d565efSmrg 292010d565efSmrgDo not attempt to use @code{cp_namespace_decls} for a namespace which is 292110d565efSmrgan alias. Instead, follow @code{DECL_NAMESPACE_ALIAS} links until you 292210d565efSmrgreach an ordinary, non-alias, namespace, and call 292310d565efSmrg@code{cp_namespace_decls} there. 292410d565efSmrg 292510d565efSmrg@item DECL_NAMESPACE_STD_P 292610d565efSmrgThis predicate holds if the namespace is the special @code{::std} 292710d565efSmrgnamespace. 292810d565efSmrg 292910d565efSmrg@item cp_namespace_decls 293010d565efSmrgThis function will return the declarations contained in the namespace, 293110d565efSmrgincluding types, overloaded functions, other namespaces, and so forth. 293210d565efSmrgIf there are no declarations, this function will return 293310d565efSmrg@code{NULL_TREE}. The declarations are connected through their 293410d565efSmrg@code{TREE_CHAIN} fields. 293510d565efSmrg 293610d565efSmrgAlthough most entries on this list will be declarations, 293710d565efSmrg@code{TREE_LIST} nodes may also appear. In this case, the 293810d565efSmrg@code{TREE_VALUE} will be an @code{OVERLOAD}. The value of the 293910d565efSmrg@code{TREE_PURPOSE} is unspecified; back ends should ignore this value. 294010d565efSmrgAs with the other kinds of declarations returned by 294110d565efSmrg@code{cp_namespace_decls}, the @code{TREE_CHAIN} will point to the next 294210d565efSmrgdeclaration in this list. 294310d565efSmrg 294410d565efSmrgFor more information on the kinds of declarations that can occur on this 294510d565efSmrglist, @xref{Declarations}. Some declarations will not appear on this 294610d565efSmrglist. In particular, no @code{FIELD_DECL}, @code{LABEL_DECL}, or 294710d565efSmrg@code{PARM_DECL} nodes will appear here. 294810d565efSmrg 294910d565efSmrgThis function cannot be used with namespaces that have 295010d565efSmrg@code{DECL_NAMESPACE_ALIAS} set. 295110d565efSmrg 295210d565efSmrg@end ftable 295310d565efSmrg 295410d565efSmrg@c --------------------------------------------------------------------- 295510d565efSmrg@c Classes 295610d565efSmrg@c --------------------------------------------------------------------- 295710d565efSmrg 295810d565efSmrg@node Classes 295910d565efSmrg@subsection Classes 296010d565efSmrg@cindex class, scope 296110d565efSmrg@tindex RECORD_TYPE 296210d565efSmrg@tindex UNION_TYPE 296310d565efSmrg@findex CLASSTYPE_DECLARED_CLASS 296410d565efSmrg@findex TYPE_BINFO 296510d565efSmrg@findex BINFO_TYPE 296610d565efSmrg@findex TYPE_FIELDS 296710d565efSmrg@findex TYPE_VFIELD 296810d565efSmrg 296910d565efSmrgBesides namespaces, the other high-level scoping construct in C++ is the 297010d565efSmrgclass. (Throughout this manual the term @dfn{class} is used to mean the 297110d565efSmrgtypes referred to in the ANSI/ISO C++ Standard as classes; these include 297210d565efSmrgtypes defined with the @code{class}, @code{struct}, and @code{union} 297310d565efSmrgkeywords.) 297410d565efSmrg 297510d565efSmrgA class type is represented by either a @code{RECORD_TYPE} or a 297610d565efSmrg@code{UNION_TYPE}. A class declared with the @code{union} tag is 297710d565efSmrgrepresented by a @code{UNION_TYPE}, while classes declared with either 297810d565efSmrgthe @code{struct} or the @code{class} tag are represented by 297910d565efSmrg@code{RECORD_TYPE}s. You can use the @code{CLASSTYPE_DECLARED_CLASS} 298010d565efSmrgmacro to discern whether or not a particular type is a @code{class} as 298110d565efSmrgopposed to a @code{struct}. This macro will be true only for classes 298210d565efSmrgdeclared with the @code{class} tag. 298310d565efSmrg 2984c7a68eb7SmrgAlmost all members are available on the @code{TYPE_FIELDS} 298510d565efSmrglist. Given one member, the next can be found by following the 298610d565efSmrg@code{TREE_CHAIN}. You should not depend in any way on the order in 298710d565efSmrgwhich fields appear on this list. All nodes on this list will be 298810d565efSmrg@samp{DECL} nodes. A @code{FIELD_DECL} is used to represent a non-static 298910d565efSmrgdata member, a @code{VAR_DECL} is used to represent a static data 299010d565efSmrgmember, and a @code{TYPE_DECL} is used to represent a type. Note that 299110d565efSmrgthe @code{CONST_DECL} for an enumeration constant will appear on this 299210d565efSmrglist, if the enumeration type was declared in the class. (Of course, 299310d565efSmrgthe @code{TYPE_DECL} for the enumeration type will appear here as well.) 299410d565efSmrgThere are no entries for base classes on this list. In particular, 299510d565efSmrgthere is no @code{FIELD_DECL} for the ``base-class portion'' of an 2996c7a68eb7Smrgobject. If a function member is overloaded, each of the overloaded 2997c7a68eb7Smrgfunctions appears; no @code{OVERLOAD} nodes appear on the @code{TYPE_FIELDS} 2998c7a68eb7Smrglist. Implicitly declared functions (including default constructors, 2999c7a68eb7Smrgcopy constructors, assignment operators, and destructors) will appear on 3000c7a68eb7Smrgthis list as well. 300110d565efSmrg 300210d565efSmrgThe @code{TYPE_VFIELD} is a compiler-generated field used to point to 300310d565efSmrgvirtual function tables. It may or may not appear on the 300410d565efSmrg@code{TYPE_FIELDS} list. However, back ends should handle the 300510d565efSmrg@code{TYPE_VFIELD} just like all the entries on the @code{TYPE_FIELDS} 300610d565efSmrglist. 300710d565efSmrg 300810d565efSmrgEvery class has an associated @dfn{binfo}, which can be obtained with 300910d565efSmrg@code{TYPE_BINFO}. Binfos are used to represent base-classes. The 301010d565efSmrgbinfo given by @code{TYPE_BINFO} is the degenerate case, whereby every 301110d565efSmrgclass is considered to be its own base-class. The base binfos for a 301210d565efSmrgparticular binfo are held in a vector, whose length is obtained with 301310d565efSmrg@code{BINFO_N_BASE_BINFOS}. The base binfos themselves are obtained 301410d565efSmrgwith @code{BINFO_BASE_BINFO} and @code{BINFO_BASE_ITERATE}. To add a 301510d565efSmrgnew binfo, use @code{BINFO_BASE_APPEND}. The vector of base binfos can 301610d565efSmrgbe obtained with @code{BINFO_BASE_BINFOS}, but normally you do not need 301710d565efSmrgto use that. The class type associated with a binfo is given by 301810d565efSmrg@code{BINFO_TYPE}. It is not always the case that @code{BINFO_TYPE 301910d565efSmrg(TYPE_BINFO (x))}, because of typedefs and qualified types. Neither is 302010d565efSmrgit the case that @code{TYPE_BINFO (BINFO_TYPE (y))} is the same binfo as 302110d565efSmrg@code{y}. The reason is that if @code{y} is a binfo representing a 302210d565efSmrgbase-class @code{B} of a derived class @code{D}, then @code{BINFO_TYPE 302310d565efSmrg(y)} will be @code{B}, and @code{TYPE_BINFO (BINFO_TYPE (y))} will be 302410d565efSmrg@code{B} as its own base-class, rather than as a base-class of @code{D}. 302510d565efSmrg 302610d565efSmrgThe access to a base type can be found with @code{BINFO_BASE_ACCESS}. 302710d565efSmrgThis will produce @code{access_public_node}, @code{access_private_node} 302810d565efSmrgor @code{access_protected_node}. If bases are always public, 302910d565efSmrg@code{BINFO_BASE_ACCESSES} may be @code{NULL}. 303010d565efSmrg 303110d565efSmrg@code{BINFO_VIRTUAL_P} is used to specify whether the binfo is inherited 303210d565efSmrgvirtually or not. The other flags, @code{BINFO_FLAG_0} to 303310d565efSmrg@code{BINFO_FLAG_6}, can be used for language specific use. 303410d565efSmrg 303510d565efSmrgThe following macros can be used on a tree node representing a class-type. 303610d565efSmrg 303710d565efSmrg@ftable @code 303810d565efSmrg@item LOCAL_CLASS_P 303910d565efSmrgThis predicate holds if the class is local class @emph{i.e.}@: declared 304010d565efSmrginside a function body. 304110d565efSmrg 304210d565efSmrg@item TYPE_POLYMORPHIC_P 304310d565efSmrgThis predicate holds if the class has at least one virtual function 304410d565efSmrg(declared or inherited). 304510d565efSmrg 304610d565efSmrg@item TYPE_HAS_DEFAULT_CONSTRUCTOR 304710d565efSmrgThis predicate holds whenever its argument represents a class-type with 304810d565efSmrgdefault constructor. 304910d565efSmrg 305010d565efSmrg@item CLASSTYPE_HAS_MUTABLE 305110d565efSmrg@itemx TYPE_HAS_MUTABLE_P 305210d565efSmrgThese predicates hold for a class-type having a mutable data member. 305310d565efSmrg 305410d565efSmrg@item CLASSTYPE_NON_POD_P 305510d565efSmrgThis predicate holds only for class-types that are not PODs. 305610d565efSmrg 305710d565efSmrg@item TYPE_HAS_NEW_OPERATOR 305810d565efSmrgThis predicate holds for a class-type that defines 305910d565efSmrg@code{operator new}. 306010d565efSmrg 306110d565efSmrg@item TYPE_HAS_ARRAY_NEW_OPERATOR 306210d565efSmrgThis predicate holds for a class-type for which 306310d565efSmrg@code{operator new[]} is defined. 306410d565efSmrg 306510d565efSmrg@item TYPE_OVERLOADS_CALL_EXPR 306610d565efSmrgThis predicate holds for class-type for which the function call 306710d565efSmrg@code{operator()} is overloaded. 306810d565efSmrg 306910d565efSmrg@item TYPE_OVERLOADS_ARRAY_REF 307010d565efSmrgThis predicate holds for a class-type that overloads 307110d565efSmrg@code{operator[]} 307210d565efSmrg 307310d565efSmrg@item TYPE_OVERLOADS_ARROW 307410d565efSmrgThis predicate holds for a class-type for which @code{operator->} is 307510d565efSmrgoverloaded. 307610d565efSmrg 307710d565efSmrg@end ftable 307810d565efSmrg 307910d565efSmrg@node Functions for C++ 308010d565efSmrg@subsection Functions for C++ 308110d565efSmrg@cindex function 308210d565efSmrg@tindex FUNCTION_DECL 308310d565efSmrg@tindex OVERLOAD 308410d565efSmrg@findex OVL_CURRENT 308510d565efSmrg@findex OVL_NEXT 308610d565efSmrg 308710d565efSmrgA function is represented by a @code{FUNCTION_DECL} node. A set of 308810d565efSmrgoverloaded functions is sometimes represented by an @code{OVERLOAD} node. 308910d565efSmrg 309010d565efSmrgAn @code{OVERLOAD} node is not a declaration, so none of the 309110d565efSmrg@samp{DECL_} macros should be used on an @code{OVERLOAD}. An 309210d565efSmrg@code{OVERLOAD} node is similar to a @code{TREE_LIST}. Use 309310d565efSmrg@code{OVL_CURRENT} to get the function associated with an 309410d565efSmrg@code{OVERLOAD} node; use @code{OVL_NEXT} to get the next 309510d565efSmrg@code{OVERLOAD} node in the list of overloaded functions. The macros 309610d565efSmrg@code{OVL_CURRENT} and @code{OVL_NEXT} are actually polymorphic; you can 309710d565efSmrguse them to work with @code{FUNCTION_DECL} nodes as well as with 309810d565efSmrgoverloads. In the case of a @code{FUNCTION_DECL}, @code{OVL_CURRENT} 309910d565efSmrgwill always return the function itself, and @code{OVL_NEXT} will always 310010d565efSmrgbe @code{NULL_TREE}. 310110d565efSmrg 310210d565efSmrgTo determine the scope of a function, you can use the 310310d565efSmrg@code{DECL_CONTEXT} macro. This macro will return the class 310410d565efSmrg(either a @code{RECORD_TYPE} or a @code{UNION_TYPE}) or namespace (a 310510d565efSmrg@code{NAMESPACE_DECL}) of which the function is a member. For a virtual 310610d565efSmrgfunction, this macro returns the class in which the function was 310710d565efSmrgactually defined, not the base class in which the virtual declaration 310810d565efSmrgoccurred. 310910d565efSmrg 311010d565efSmrgIf a friend function is defined in a class scope, the 311110d565efSmrg@code{DECL_FRIEND_CONTEXT} macro can be used to determine the class in 311210d565efSmrgwhich it was defined. For example, in 311310d565efSmrg@smallexample 311410d565efSmrgclass C @{ friend void f() @{@} @}; 311510d565efSmrg@end smallexample 311610d565efSmrg@noindent 311710d565efSmrgthe @code{DECL_CONTEXT} for @code{f} will be the 311810d565efSmrg@code{global_namespace}, but the @code{DECL_FRIEND_CONTEXT} will be the 311910d565efSmrg@code{RECORD_TYPE} for @code{C}. 312010d565efSmrg 312110d565efSmrg 312210d565efSmrgThe following macros and functions can be used on a @code{FUNCTION_DECL}: 312310d565efSmrg@ftable @code 312410d565efSmrg@item DECL_MAIN_P 312510d565efSmrgThis predicate holds for a function that is the program entry point 312610d565efSmrg@code{::code}. 312710d565efSmrg 312810d565efSmrg@item DECL_LOCAL_FUNCTION_P 312910d565efSmrgThis predicate holds if the function was declared at block scope, even 313010d565efSmrgthough it has a global scope. 313110d565efSmrg 313210d565efSmrg@item DECL_ANTICIPATED 313310d565efSmrgThis predicate holds if the function is a built-in function but its 313410d565efSmrgprototype is not yet explicitly declared. 313510d565efSmrg 313610d565efSmrg@item DECL_EXTERN_C_FUNCTION_P 313710d565efSmrgThis predicate holds if the function is declared as an 313810d565efSmrg`@code{extern "C"}' function. 313910d565efSmrg 314010d565efSmrg@item DECL_LINKONCE_P 314110d565efSmrgThis macro holds if multiple copies of this function may be emitted in 314210d565efSmrgvarious translation units. It is the responsibility of the linker to 314310d565efSmrgmerge the various copies. Template instantiations are the most common 314410d565efSmrgexample of functions for which @code{DECL_LINKONCE_P} holds; G++ 314510d565efSmrginstantiates needed templates in all translation units which require them, 314610d565efSmrgand then relies on the linker to remove duplicate instantiations. 314710d565efSmrg 314810d565efSmrgFIXME: This macro is not yet implemented. 314910d565efSmrg 315010d565efSmrg@item DECL_FUNCTION_MEMBER_P 315110d565efSmrgThis macro holds if the function is a member of a class, rather than a 315210d565efSmrgmember of a namespace. 315310d565efSmrg 315410d565efSmrg@item DECL_STATIC_FUNCTION_P 315510d565efSmrgThis predicate holds if the function a static member function. 315610d565efSmrg 315710d565efSmrg@item DECL_NONSTATIC_MEMBER_FUNCTION_P 315810d565efSmrgThis macro holds for a non-static member function. 315910d565efSmrg 316010d565efSmrg@item DECL_CONST_MEMFUNC_P 316110d565efSmrgThis predicate holds for a @code{const}-member function. 316210d565efSmrg 316310d565efSmrg@item DECL_VOLATILE_MEMFUNC_P 316410d565efSmrgThis predicate holds for a @code{volatile}-member function. 316510d565efSmrg 316610d565efSmrg@item DECL_CONSTRUCTOR_P 316710d565efSmrgThis macro holds if the function is a constructor. 316810d565efSmrg 316910d565efSmrg@item DECL_NONCONVERTING_P 317010d565efSmrgThis predicate holds if the constructor is a non-converting constructor. 317110d565efSmrg 317210d565efSmrg@item DECL_COMPLETE_CONSTRUCTOR_P 317310d565efSmrgThis predicate holds for a function which is a constructor for an object 317410d565efSmrgof a complete type. 317510d565efSmrg 317610d565efSmrg@item DECL_BASE_CONSTRUCTOR_P 317710d565efSmrgThis predicate holds for a function which is a constructor for a base 317810d565efSmrgclass sub-object. 317910d565efSmrg 318010d565efSmrg@item DECL_COPY_CONSTRUCTOR_P 318110d565efSmrgThis predicate holds for a function which is a copy-constructor. 318210d565efSmrg 318310d565efSmrg@item DECL_DESTRUCTOR_P 318410d565efSmrgThis macro holds if the function is a destructor. 318510d565efSmrg 318610d565efSmrg@item DECL_COMPLETE_DESTRUCTOR_P 318710d565efSmrgThis predicate holds if the function is the destructor for an object a 318810d565efSmrgcomplete type. 318910d565efSmrg 319010d565efSmrg@item DECL_OVERLOADED_OPERATOR_P 319110d565efSmrgThis macro holds if the function is an overloaded operator. 319210d565efSmrg 319310d565efSmrg@item DECL_CONV_FN_P 319410d565efSmrgThis macro holds if the function is a type-conversion operator. 319510d565efSmrg 319610d565efSmrg@item DECL_GLOBAL_CTOR_P 319710d565efSmrgThis predicate holds if the function is a file-scope initialization 319810d565efSmrgfunction. 319910d565efSmrg 320010d565efSmrg@item DECL_GLOBAL_DTOR_P 320110d565efSmrgThis predicate holds if the function is a file-scope finalization 320210d565efSmrgfunction. 320310d565efSmrg 320410d565efSmrg@item DECL_THUNK_P 320510d565efSmrgThis predicate holds if the function is a thunk. 320610d565efSmrg 320710d565efSmrgThese functions represent stub code that adjusts the @code{this} pointer 320810d565efSmrgand then jumps to another function. When the jumped-to function 320910d565efSmrgreturns, control is transferred directly to the caller, without 321010d565efSmrgreturning to the thunk. The first parameter to the thunk is always the 321110d565efSmrg@code{this} pointer; the thunk should add @code{THUNK_DELTA} to this 321210d565efSmrgvalue. (The @code{THUNK_DELTA} is an @code{int}, not an 321310d565efSmrg@code{INTEGER_CST}.) 321410d565efSmrg 321510d565efSmrgThen, if @code{THUNK_VCALL_OFFSET} (an @code{INTEGER_CST}) is nonzero 321610d565efSmrgthe adjusted @code{this} pointer must be adjusted again. The complete 321710d565efSmrgcalculation is given by the following pseudo-code: 321810d565efSmrg 321910d565efSmrg@smallexample 322010d565efSmrgthis += THUNK_DELTA 322110d565efSmrgif (THUNK_VCALL_OFFSET) 322210d565efSmrg this += (*((ptrdiff_t **) this))[THUNK_VCALL_OFFSET] 322310d565efSmrg@end smallexample 322410d565efSmrg 322510d565efSmrgFinally, the thunk should jump to the location given 322610d565efSmrgby @code{DECL_INITIAL}; this will always be an expression for the 322710d565efSmrgaddress of a function. 322810d565efSmrg 322910d565efSmrg@item DECL_NON_THUNK_FUNCTION_P 323010d565efSmrgThis predicate holds if the function is @emph{not} a thunk function. 323110d565efSmrg 323210d565efSmrg@item GLOBAL_INIT_PRIORITY 323310d565efSmrgIf either @code{DECL_GLOBAL_CTOR_P} or @code{DECL_GLOBAL_DTOR_P} holds, 323410d565efSmrgthen this gives the initialization priority for the function. The 323510d565efSmrglinker will arrange that all functions for which 323610d565efSmrg@code{DECL_GLOBAL_CTOR_P} holds are run in increasing order of priority 323710d565efSmrgbefore @code{main} is called. When the program exits, all functions for 323810d565efSmrgwhich @code{DECL_GLOBAL_DTOR_P} holds are run in the reverse order. 323910d565efSmrg 324010d565efSmrg@item TYPE_RAISES_EXCEPTIONS 324110d565efSmrgThis macro returns the list of exceptions that a (member-)function can 324210d565efSmrgraise. The returned list, if non @code{NULL}, is comprised of nodes 324310d565efSmrgwhose @code{TREE_VALUE} represents a type. 324410d565efSmrg 324510d565efSmrg@item TYPE_NOTHROW_P 324610d565efSmrgThis predicate holds when the exception-specification of its arguments 324710d565efSmrgis of the form `@code{()}'. 324810d565efSmrg 324910d565efSmrg@item DECL_ARRAY_DELETE_OPERATOR_P 325010d565efSmrgThis predicate holds if the function an overloaded 325110d565efSmrg@code{operator delete[]}. 325210d565efSmrg 325310d565efSmrg@end ftable 325410d565efSmrg 325510d565efSmrg@c --------------------------------------------------------------------- 325610d565efSmrg@c Function Bodies 325710d565efSmrg@c --------------------------------------------------------------------- 325810d565efSmrg 325910d565efSmrg@node Statements for C++ 326010d565efSmrg@subsection Statements for C++ 326110d565efSmrg@cindex statements 326210d565efSmrg@tindex BREAK_STMT 326310d565efSmrg@tindex CLEANUP_STMT 326410d565efSmrg@findex CLEANUP_DECL 326510d565efSmrg@findex CLEANUP_EXPR 326610d565efSmrg@tindex CONTINUE_STMT 326710d565efSmrg@tindex DECL_STMT 326810d565efSmrg@findex DECL_STMT_DECL 326910d565efSmrg@tindex DO_STMT 327010d565efSmrg@findex DO_BODY 327110d565efSmrg@findex DO_COND 327210d565efSmrg@tindex EMPTY_CLASS_EXPR 327310d565efSmrg@tindex EXPR_STMT 327410d565efSmrg@findex EXPR_STMT_EXPR 327510d565efSmrg@tindex FOR_STMT 327610d565efSmrg@findex FOR_INIT_STMT 327710d565efSmrg@findex FOR_COND 327810d565efSmrg@findex FOR_EXPR 327910d565efSmrg@findex FOR_BODY 328010d565efSmrg@tindex HANDLER 328110d565efSmrg@tindex IF_STMT 328210d565efSmrg@findex IF_COND 328310d565efSmrg@findex THEN_CLAUSE 328410d565efSmrg@findex ELSE_CLAUSE 328510d565efSmrg@tindex RETURN_STMT 328610d565efSmrg@findex RETURN_EXPR 328710d565efSmrg@tindex SUBOBJECT 328810d565efSmrg@findex SUBOBJECT_CLEANUP 328910d565efSmrg@tindex SWITCH_STMT 329010d565efSmrg@findex SWITCH_COND 329110d565efSmrg@findex SWITCH_BODY 329210d565efSmrg@tindex TRY_BLOCK 329310d565efSmrg@findex TRY_STMTS 329410d565efSmrg@findex TRY_HANDLERS 329510d565efSmrg@findex HANDLER_PARMS 329610d565efSmrg@findex HANDLER_BODY 329710d565efSmrg@findex USING_STMT 329810d565efSmrg@tindex WHILE_STMT 329910d565efSmrg@findex WHILE_BODY 330010d565efSmrg@findex WHILE_COND 330110d565efSmrg 330210d565efSmrgA function that has a definition in the current translation unit will 330310d565efSmrghave a non-@code{NULL} @code{DECL_INITIAL}. However, back ends should not make 330410d565efSmrguse of the particular value given by @code{DECL_INITIAL}. 330510d565efSmrg 330610d565efSmrgThe @code{DECL_SAVED_TREE} macro will give the complete body of the 330710d565efSmrgfunction. 330810d565efSmrg 330910d565efSmrg@subsubsection Statements 331010d565efSmrg 331110d565efSmrgThere are tree nodes corresponding to all of the source-level 331210d565efSmrgstatement constructs, used within the C and C++ frontends. These are 331310d565efSmrgenumerated here, together with a list of the various macros that can 331410d565efSmrgbe used to obtain information about them. There are a few macros that 331510d565efSmrgcan be used with all statements: 331610d565efSmrg 331710d565efSmrg@ftable @code 331810d565efSmrg@item STMT_IS_FULL_EXPR_P 331910d565efSmrgIn C++, statements normally constitute ``full expressions''; temporaries 332010d565efSmrgcreated during a statement are destroyed when the statement is complete. 332110d565efSmrgHowever, G++ sometimes represents expressions by statements; these 332210d565efSmrgstatements will not have @code{STMT_IS_FULL_EXPR_P} set. Temporaries 332310d565efSmrgcreated during such statements should be destroyed when the innermost 332410d565efSmrgenclosing statement with @code{STMT_IS_FULL_EXPR_P} set is exited. 332510d565efSmrg 332610d565efSmrg@end ftable 332710d565efSmrg 332810d565efSmrgHere is the list of the various statement nodes, and the macros used to 332910d565efSmrgaccess them. This documentation describes the use of these nodes in 333010d565efSmrgnon-template functions (including instantiations of template functions). 333110d565efSmrgIn template functions, the same nodes are used, but sometimes in 333210d565efSmrgslightly different ways. 333310d565efSmrg 333410d565efSmrgMany of the statements have substatements. For example, a @code{while} 333510d565efSmrgloop will have a body, which is itself a statement. If the substatement 333610d565efSmrgis @code{NULL_TREE}, it is considered equivalent to a statement 333710d565efSmrgconsisting of a single @code{;}, i.e., an expression statement in which 333810d565efSmrgthe expression has been omitted. A substatement may in fact be a list 333910d565efSmrgof statements, connected via their @code{TREE_CHAIN}s. So, you should 334010d565efSmrgalways process the statement tree by looping over substatements, like 334110d565efSmrgthis: 334210d565efSmrg@smallexample 334310d565efSmrgvoid process_stmt (stmt) 334410d565efSmrg tree stmt; 334510d565efSmrg@{ 334610d565efSmrg while (stmt) 334710d565efSmrg @{ 334810d565efSmrg switch (TREE_CODE (stmt)) 334910d565efSmrg @{ 335010d565efSmrg case IF_STMT: 335110d565efSmrg process_stmt (THEN_CLAUSE (stmt)); 335210d565efSmrg /* @r{More processing here.} */ 335310d565efSmrg break; 335410d565efSmrg 335510d565efSmrg @dots{} 335610d565efSmrg @} 335710d565efSmrg 335810d565efSmrg stmt = TREE_CHAIN (stmt); 335910d565efSmrg @} 336010d565efSmrg@} 336110d565efSmrg@end smallexample 336210d565efSmrgIn other words, while the @code{then} clause of an @code{if} statement 336310d565efSmrgin C++ can be only one statement (although that one statement may be a 336410d565efSmrgcompound statement), the intermediate representation will sometimes use 336510d565efSmrgseveral statements chained together. 336610d565efSmrg 336710d565efSmrg@table @code 336810d565efSmrg@item BREAK_STMT 336910d565efSmrg 337010d565efSmrgUsed to represent a @code{break} statement. There are no additional 337110d565efSmrgfields. 337210d565efSmrg 337310d565efSmrg@item CLEANUP_STMT 337410d565efSmrg 337510d565efSmrgUsed to represent an action that should take place upon exit from the 337610d565efSmrgenclosing scope. Typically, these actions are calls to destructors for 337710d565efSmrglocal objects, but back ends cannot rely on this fact. If these nodes 337810d565efSmrgare in fact representing such destructors, @code{CLEANUP_DECL} will be 337910d565efSmrgthe @code{VAR_DECL} destroyed. Otherwise, @code{CLEANUP_DECL} will be 338010d565efSmrg@code{NULL_TREE}. In any case, the @code{CLEANUP_EXPR} is the 338110d565efSmrgexpression to execute. The cleanups executed on exit from a scope 338210d565efSmrgshould be run in the reverse order of the order in which the associated 338310d565efSmrg@code{CLEANUP_STMT}s were encountered. 338410d565efSmrg 338510d565efSmrg@item CONTINUE_STMT 338610d565efSmrg 338710d565efSmrgUsed to represent a @code{continue} statement. There are no additional 338810d565efSmrgfields. 338910d565efSmrg 339010d565efSmrg@item CTOR_STMT 339110d565efSmrg 339210d565efSmrgUsed to mark the beginning (if @code{CTOR_BEGIN_P} holds) or end (if 339310d565efSmrg@code{CTOR_END_P} holds of the main body of a constructor. See also 339410d565efSmrg@code{SUBOBJECT} for more information on how to use these nodes. 339510d565efSmrg 339610d565efSmrg@item DO_STMT 339710d565efSmrg 339810d565efSmrgUsed to represent a @code{do} loop. The body of the loop is given by 339910d565efSmrg@code{DO_BODY} while the termination condition for the loop is given by 340010d565efSmrg@code{DO_COND}. The condition for a @code{do}-statement is always an 340110d565efSmrgexpression. 340210d565efSmrg 340310d565efSmrg@item EMPTY_CLASS_EXPR 340410d565efSmrg 340510d565efSmrgUsed to represent a temporary object of a class with no data whose 340610d565efSmrgaddress is never taken. (All such objects are interchangeable.) The 340710d565efSmrg@code{TREE_TYPE} represents the type of the object. 340810d565efSmrg 340910d565efSmrg@item EXPR_STMT 341010d565efSmrg 341110d565efSmrgUsed to represent an expression statement. Use @code{EXPR_STMT_EXPR} to 341210d565efSmrgobtain the expression. 341310d565efSmrg 341410d565efSmrg@item FOR_STMT 341510d565efSmrg 341610d565efSmrgUsed to represent a @code{for} statement. The @code{FOR_INIT_STMT} is 341710d565efSmrgthe initialization statement for the loop. The @code{FOR_COND} is the 341810d565efSmrgtermination condition. The @code{FOR_EXPR} is the expression executed 341910d565efSmrgright before the @code{FOR_COND} on each loop iteration; often, this 342010d565efSmrgexpression increments a counter. The body of the loop is given by 342110d565efSmrg@code{FOR_BODY}. Note that @code{FOR_INIT_STMT} and @code{FOR_BODY} 342210d565efSmrgreturn statements, while @code{FOR_COND} and @code{FOR_EXPR} return 342310d565efSmrgexpressions. 342410d565efSmrg 342510d565efSmrg@item HANDLER 342610d565efSmrg 342710d565efSmrgUsed to represent a C++ @code{catch} block. The @code{HANDLER_TYPE} 342810d565efSmrgis the type of exception that will be caught by this handler; it is 342910d565efSmrgequal (by pointer equality) to @code{NULL} if this handler is for all 343010d565efSmrgtypes. @code{HANDLER_PARMS} is the @code{DECL_STMT} for the catch 343110d565efSmrgparameter, and @code{HANDLER_BODY} is the code for the block itself. 343210d565efSmrg 343310d565efSmrg@item IF_STMT 343410d565efSmrg 343510d565efSmrgUsed to represent an @code{if} statement. The @code{IF_COND} is the 343610d565efSmrgexpression. 343710d565efSmrg 343810d565efSmrgIf the condition is a @code{TREE_LIST}, then the @code{TREE_PURPOSE} is 343910d565efSmrga statement (usually a @code{DECL_STMT}). Each time the condition is 344010d565efSmrgevaluated, the statement should be executed. Then, the 344110d565efSmrg@code{TREE_VALUE} should be used as the conditional expression itself. 344210d565efSmrgThis representation is used to handle C++ code like this: 344310d565efSmrg 344410d565efSmrgC++ distinguishes between this and @code{COND_EXPR} for handling templates. 344510d565efSmrg 344610d565efSmrg@smallexample 344710d565efSmrgif (int i = 7) @dots{} 344810d565efSmrg@end smallexample 344910d565efSmrg 345010d565efSmrgwhere there is a new local variable (or variables) declared within the 345110d565efSmrgcondition. 345210d565efSmrg 345310d565efSmrgThe @code{THEN_CLAUSE} represents the statement given by the @code{then} 345410d565efSmrgcondition, while the @code{ELSE_CLAUSE} represents the statement given 345510d565efSmrgby the @code{else} condition. 345610d565efSmrg 345710d565efSmrg@item SUBOBJECT 345810d565efSmrg 345910d565efSmrgIn a constructor, these nodes are used to mark the point at which a 346010d565efSmrgsubobject of @code{this} is fully constructed. If, after this point, an 346110d565efSmrgexception is thrown before a @code{CTOR_STMT} with @code{CTOR_END_P} set 346210d565efSmrgis encountered, the @code{SUBOBJECT_CLEANUP} must be executed. The 346310d565efSmrgcleanups must be executed in the reverse order in which they appear. 346410d565efSmrg 346510d565efSmrg@item SWITCH_STMT 346610d565efSmrg 346710d565efSmrgUsed to represent a @code{switch} statement. The @code{SWITCH_STMT_COND} 346810d565efSmrgis the expression on which the switch is occurring. See the documentation 346910d565efSmrgfor an @code{IF_STMT} for more information on the representation used 347010d565efSmrgfor the condition. The @code{SWITCH_STMT_BODY} is the body of the switch 347110d565efSmrgstatement. The @code{SWITCH_STMT_TYPE} is the original type of switch 347210d565efSmrgexpression as given in the source, before any compiler conversions. 347310d565efSmrg 347410d565efSmrg@item TRY_BLOCK 347510d565efSmrgUsed to represent a @code{try} block. The body of the try block is 347610d565efSmrggiven by @code{TRY_STMTS}. Each of the catch blocks is a @code{HANDLER} 347710d565efSmrgnode. The first handler is given by @code{TRY_HANDLERS}. Subsequent 347810d565efSmrghandlers are obtained by following the @code{TREE_CHAIN} link from one 347910d565efSmrghandler to the next. The body of the handler is given by 348010d565efSmrg@code{HANDLER_BODY}. 348110d565efSmrg 348210d565efSmrgIf @code{CLEANUP_P} holds of the @code{TRY_BLOCK}, then the 348310d565efSmrg@code{TRY_HANDLERS} will not be a @code{HANDLER} node. Instead, it will 348410d565efSmrgbe an expression that should be executed if an exception is thrown in 348510d565efSmrgthe try block. It must rethrow the exception after executing that code. 348610d565efSmrgAnd, if an exception is thrown while the expression is executing, 348710d565efSmrg@code{terminate} must be called. 348810d565efSmrg 348910d565efSmrg@item USING_STMT 349010d565efSmrgUsed to represent a @code{using} directive. The namespace is given by 349110d565efSmrg@code{USING_STMT_NAMESPACE}, which will be a NAMESPACE_DECL@. This node 349210d565efSmrgis needed inside template functions, to implement using directives 349310d565efSmrgduring instantiation. 349410d565efSmrg 349510d565efSmrg@item WHILE_STMT 349610d565efSmrg 349710d565efSmrgUsed to represent a @code{while} loop. The @code{WHILE_COND} is the 349810d565efSmrgtermination condition for the loop. See the documentation for an 349910d565efSmrg@code{IF_STMT} for more information on the representation used for the 350010d565efSmrgcondition. 350110d565efSmrg 350210d565efSmrgThe @code{WHILE_BODY} is the body of the loop. 350310d565efSmrg 350410d565efSmrg@end table 350510d565efSmrg 350610d565efSmrg@node C++ Expressions 350710d565efSmrg@subsection C++ Expressions 350810d565efSmrg 350910d565efSmrgThis section describes expressions specific to the C and C++ front 351010d565efSmrgends. 351110d565efSmrg 351210d565efSmrg@table @code 351310d565efSmrg@item TYPEID_EXPR 351410d565efSmrg 351510d565efSmrgUsed to represent a @code{typeid} expression. 351610d565efSmrg 351710d565efSmrg@item NEW_EXPR 351810d565efSmrg@itemx VEC_NEW_EXPR 351910d565efSmrg 352010d565efSmrgUsed to represent a call to @code{new} and @code{new[]} respectively. 352110d565efSmrg 352210d565efSmrg@item DELETE_EXPR 352310d565efSmrg@itemx VEC_DELETE_EXPR 352410d565efSmrg 352510d565efSmrgUsed to represent a call to @code{delete} and @code{delete[]} respectively. 352610d565efSmrg 352710d565efSmrg@item MEMBER_REF 352810d565efSmrg 352910d565efSmrgRepresents a reference to a member of a class. 353010d565efSmrg 353110d565efSmrg@item THROW_EXPR 353210d565efSmrg 353310d565efSmrgRepresents an instance of @code{throw} in the program. Operand 0, 353410d565efSmrgwhich is the expression to throw, may be @code{NULL_TREE}. 353510d565efSmrg 353610d565efSmrg 353710d565efSmrg@item AGGR_INIT_EXPR 353810d565efSmrgAn @code{AGGR_INIT_EXPR} represents the initialization as the return 353910d565efSmrgvalue of a function call, or as the result of a constructor. An 354010d565efSmrg@code{AGGR_INIT_EXPR} will only appear as a full-expression, or as the 354110d565efSmrgsecond operand of a @code{TARGET_EXPR}. @code{AGGR_INIT_EXPR}s have 354210d565efSmrga representation similar to that of @code{CALL_EXPR}s. You can use 354310d565efSmrgthe @code{AGGR_INIT_EXPR_FN} and @code{AGGR_INIT_EXPR_ARG} macros to access 354410d565efSmrgthe function to call and the arguments to pass. 354510d565efSmrg 354610d565efSmrgIf @code{AGGR_INIT_VIA_CTOR_P} holds of the @code{AGGR_INIT_EXPR}, then 354710d565efSmrgthe initialization is via a constructor call. The address of the 354810d565efSmrg@code{AGGR_INIT_EXPR_SLOT} operand, which is always a @code{VAR_DECL}, 354910d565efSmrgis taken, and this value replaces the first argument in the argument 355010d565efSmrglist. 355110d565efSmrg 355210d565efSmrgIn either case, the expression is void. 355310d565efSmrg 355410d565efSmrg 355510d565efSmrg@end table 3556