gccint: Tree overview

1 
1 11.2 Overview
1 =============
1 
1 The central data structure used by the internal representation is the
1 'tree'.  These nodes, while all of the C type 'tree', are of many
1 varieties.  A 'tree' is a pointer type, but the object to which it
1 points may be of a variety of types.  From this point forward, we will
1 refer to trees in ordinary type, rather than in 'this font', except when
1 talking about the actual C type 'tree'.
1 
1  You can tell what kind of node a particular tree is by using the
1 'TREE_CODE' macro.  Many, many macros take trees as input and return
1 trees as output.  However, most macros require a certain kind of tree
1 node as input.  In other words, there is a type-system for trees, but it
1 is not reflected in the C type-system.
1 
1  For safety, it is useful to configure GCC with '--enable-checking'.
1 Although this results in a significant performance penalty (since all
1 tree types are checked at run-time), and is therefore inappropriate in a
1 release version, it is extremely helpful during the development process.
1 
1  Many macros behave as predicates.  Many, although not all, of these
1 predicates end in '_P'.  Do not rely on the result type of these macros
1 being of any particular type.  You may, however, rely on the fact that
1 the type can be compared to '0', so that statements like
1      if (TEST_P (t) && !TEST_P (y))
1        x = 1;
1 and
1      int i = (TEST_P (t) != 0);
1 are legal.  Macros that return 'int' values now may be changed to return
1 'tree' values, or other pointers in the future.  Even those that
1 continue to return 'int' may return multiple nonzero codes where
1 previously they returned only zero and one.  Therefore, you should not
1 write code like
1      if (TEST_P (t) == 1)
1 as this code is not guaranteed to work correctly in the future.
1 
1  You should not take the address of values returned by the macros or
1 functions described here.  In particular, no guarantee is given that the
1 values are lvalues.
1 
1  In general, the names of macros are all in uppercase, while the names
1 of functions are entirely in lowercase.  There are rare exceptions to
1 this rule.  You should assume that any macro or function whose name is
1 made up entirely of uppercase letters may evaluate its arguments more
1 than once.  You may assume that a macro or function whose name is made
1 up entirely of lowercase letters will evaluate its arguments only once.
1 
1  The 'error_mark_node' is a special tree.  Its tree code is
1 'ERROR_MARK', but since there is only ever one node with that code, the
1 usual practice is to compare the tree against 'error_mark_node'.  (This
1 test is just a test for pointer equality.)  If an error has occurred
1 during front-end processing the flag 'errorcount' will be set.  If the
1 front end has encountered code it cannot handle, it will issue a message
1 to the user and set 'sorrycount'.  When these flags are set, any macro
1 or function which normally returns a tree of a particular kind may
1 instead return the 'error_mark_node'.  Thus, if you intend to do any
1 processing of erroneous code, you must be prepared to deal with the
1 'error_mark_node'.
1 
1  Occasionally, a particular tree slot (like an operand to an expression,
1 or a particular field in a declaration) will be referred to as "reserved
1 for the back end".  These slots are used to store RTL when the tree is
1 converted to RTL for use by the GCC back end.  However, if that process
1 is not taking place (e.g., if the front end is being hooked up to an
1 intelligent editor), then those slots may be used by the back end
1 presently in use.
1 
1  If you encounter situations that do not match this documentation, such
1 as tree nodes of types not mentioned here, or macros documented to
1 return entities of a particular kind that instead return entities of
1 some different kind, you have found a bug, either in the front end or in
1 the documentation.  Please report these bugs as you would any other bug.
1 

Menu