gccint: Per-Function Data

1 
1 18.4 Defining data structures for per-function information.
1 ===========================================================
1 
1 If the target needs to store information on a per-function basis, GCC
1 provides a macro and a couple of variables to allow this.  Note, just
1 using statics to store the information is a bad idea, since GCC supports
1 nested functions, so you can be halfway through encoding one function
1 when another one comes along.
1 
1  GCC defines a data structure called 'struct function' which contains
1 all of the data specific to an individual function.  This structure
1 contains a field called 'machine' whose type is 'struct machine_function
1 *', which can be used by targets to point to their own specific data.
1 
1  If a target needs per-function specific data it should define the type
1 'struct machine_function' and also the macro 'INIT_EXPANDERS'.  This
1 macro should be used to initialize the function pointer
1 'init_machine_status'.  This pointer is explained below.
1 
1  One typical use of per-function, target specific data is to create an
1 RTX to hold the register containing the function's return address.  This
1 RTX can then be used to implement the '__builtin_return_address'
1 function, for level 0.
1 
1  Note--earlier implementations of GCC used a single data area to hold
1 all of the per-function information.  Thus when processing of a nested
1 function began the old per-function data had to be pushed onto a stack,
1 and when the processing was finished, it had to be popped off the stack.
1 GCC used to provide function pointers called 'save_machine_status' and
1 'restore_machine_status' to handle the saving and restoring of the
1 target specific information.  Since the single data area approach is no
1 longer used, these pointers are no longer supported.
1 
1  -- Macro: INIT_EXPANDERS
1      Macro called to initialize any target specific information.  This
1      macro is called once per function, before generation of any RTL has
1      begun.  The intention of this macro is to allow the initialization
1      of the function pointer 'init_machine_status'.
1 
1  -- Variable: void (*)(struct function *) init_machine_status
1      If this function pointer is non-'NULL' it will be called once per
1      function, before function compilation starts, in order to allow the
1      target to perform any target specific initialization of the 'struct
1      function' structure.  It is intended that this would be used to
1      initialize the 'machine' of that structure.
1 
1      'struct machine_function' structures are expected to be freed by
1      GC.  Generally, any memory that they reference must be allocated by
1      using GC allocation, including the structure itself.
1