gccint: Function Basics

1 
1 11.8.1 Function Basics
1 ----------------------
1 
1 A function has four core parts: the name, the parameters, the result,
1 and the body.  The following macros and functions access these parts of
1 a 'FUNCTION_DECL' as well as other basic features:
1 'DECL_NAME'
1      This macro returns the unqualified name of the function, as an
1      'IDENTIFIER_NODE'.  For an instantiation of a function template,
1      the 'DECL_NAME' is the unqualified name of the template, not
1      something like 'f<int>'.  The value of 'DECL_NAME' is undefined
1      when used on a constructor, destructor, overloaded operator, or
1      type-conversion operator, or any function that is implicitly
1      generated by the compiler.  See below for macros that can be used
1      to distinguish these cases.
1 
1 'DECL_ASSEMBLER_NAME'
1      This macro returns the mangled name of the function, also an
1      'IDENTIFIER_NODE'.  This name does not contain leading underscores
1      on systems that prefix all identifiers with underscores.  The
1      mangled name is computed in the same way on all platforms; if
1      special processing is required to deal with the object file format
1      used on a particular platform, it is the responsibility of the back
1      end to perform those modifications.  (Of course, the back end
1      should not modify 'DECL_ASSEMBLER_NAME' itself.)
1 
1      Using 'DECL_ASSEMBLER_NAME' will cause additional memory to be
1      allocated (for the mangled name of the entity) so it should be used
1      only when emitting assembly code.  It should not be used within the
1      optimizers to determine whether or not two declarations are the
1      same, even though some of the existing optimizers do use it in that
1      way.  These uses will be removed over time.
1 
1 'DECL_ARGUMENTS'
1      This macro returns the 'PARM_DECL' for the first argument to the
1      function.  Subsequent 'PARM_DECL' nodes can be obtained by
1      following the 'TREE_CHAIN' links.
1 
1 'DECL_RESULT'
1      This macro returns the 'RESULT_DECL' for the function.
1 
1 'DECL_SAVED_TREE'
1      This macro returns the complete body of the function.
1 
1 'TREE_TYPE'
1      This macro returns the 'FUNCTION_TYPE' or 'METHOD_TYPE' for the
1      function.
1 
1 'DECL_INITIAL'
1      A function that has a definition in the current translation unit
1      will have a non-'NULL' 'DECL_INITIAL'.  However, back ends should
1      not make use of the particular value given by 'DECL_INITIAL'.
1 
1      It should contain a tree of 'BLOCK' nodes that mirrors the scopes
1      that variables are bound in the function.  Each block contains a
1      list of decls declared in a basic block, a pointer to a chain of
1      blocks at the next lower scope level, then a pointer to the next
1      block at the same level and a backpointer to the parent 'BLOCK' or
1      'FUNCTION_DECL'.  So given a function as follows:
1 
1           void foo()
1           {
1             int a;
1             {
1               int b;
1             }
1             int c;
1           }
1 
1      you would get the following:
1 
1           tree foo = FUNCTION_DECL;
1           tree decl_a = VAR_DECL;
1           tree decl_b = VAR_DECL;
1           tree decl_c = VAR_DECL;
1           tree block_a = BLOCK;
1           tree block_b = BLOCK;
1           tree block_c = BLOCK;
1           BLOCK_VARS(block_a) = decl_a;
1           BLOCK_SUBBLOCKS(block_a) = block_b;
1           BLOCK_CHAIN(block_a) = block_c;
1           BLOCK_SUPERCONTEXT(block_a) = foo;
1           BLOCK_VARS(block_b) = decl_b;
1           BLOCK_SUPERCONTEXT(block_b) = block_a;
1           BLOCK_VARS(block_c) = decl_c;
1           BLOCK_SUPERCONTEXT(block_c) = foo;
1           DECL_INITIAL(foo) = block_a;
1