This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RFA: Remocal of {save|restore}_machine_status


Hi Guys,

  The last of the ports that used to use save_machine_status and
  restore_machine_status have been updated so the patch below removes
  these obsoleted pointers.  It also adds a section to tm.texi
  documenting the pointers and the INIT_EXPANDERS macro.  

  One thought that occurred to me whilst writing this is whether
  INIT_EXPANDERS is really a good place to initialise these pointers.
  Most ports do this, but it seems a waste since the pointers (once
  initialised) never change, so it would be just as easy to initialise
  them in a once-per-compilation called function, eg OVERRIDE_OPTIONS.

  May I apply this patch ?

Cheers
	Nick

2001-01-10  Nick Clifton  <nickc@redhat.com>

	* function.h (save_machine_status): Delete.
	(restore_machine_status): Delete.
	Amend comment describing {init|mark|free}_machine_status.

	* function.c (save_machine_status): Delete.
	(restore_machine_status): Delete.
	Amend comment describing {init|mark|free}_machine_status.
	(push_function_context_to): Remove invocation of
	save_machine_status.
	(pop_function_context_from): Remove invocation of
	restore_machine_status.

	* emit-rtl.c (init_emit_once): Amend comment describing
	{init|mark|free}_machine_status. 

	* tm.texi (Per-Function Data): New node.  Describe the
	INIT_EXPANDERS macro and the {init|mark|free}_machine_status
	function pointers.

Index: function.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.h,v
retrieving revision 1.58
diff -p -r1.58 function.h
*** function.h	2000/11/30 06:31:17	1.58
--- function.h	2001/01/10 19:40:35
*************** extern HOST_WIDE_INT get_frame_size	PARA
*** 556,569 ****
  /* Likewise, but for a different than the current function.  */
  extern HOST_WIDE_INT get_func_frame_size	PARAMS ((struct function *));
  
! /* These variables hold pointers to functions to
!    save and restore machine-specific data,
!    in push_function_context and pop_function_context.  */
  extern void (*init_machine_status)	PARAMS ((struct function *));
- extern void (*mark_machine_status)	PARAMS ((struct function *));
- extern void (*save_machine_status)	PARAMS ((struct function *));
- extern void (*restore_machine_status)	PARAMS ((struct function *));
  extern void (*free_machine_status)	PARAMS ((struct function *));
  
  /* Likewise, but for language-specific data.  */
  extern void (*init_lang_status)         PARAMS ((struct function *));
--- 556,569 ----
  /* Likewise, but for a different than the current function.  */
  extern HOST_WIDE_INT get_func_frame_size	PARAMS ((struct function *));
  
! /* These variables hold pointers to functions to create and destroy
!    target specific, per-function data structures.  */
  extern void (*init_machine_status)	PARAMS ((struct function *));
  extern void (*free_machine_status)	PARAMS ((struct function *));
+ /* This variable holds a pointer to a function to register any
+    data items in the target specific, per-function data structure
+    that will need garbage collection.  */
+ extern void (*mark_machine_status)	PARAMS ((struct function *));
  
  /* Likewise, but for language-specific data.  */
  extern void (*init_lang_status)         PARAMS ((struct function *));

Index: function.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.c,v
retrieving revision 1.243
diff -p -r1.243 function.c
*** function.c	2001/01/10 18:35:50	1.243
--- function.c	2001/01/10 19:40:35
*************** int current_function_uses_only_leaf_regs
*** 129,142 ****
     assign_stack_local uses frame_pointer_rtx when this is nonzero.  */
  static int virtuals_instantiated;
  
! /* These variables hold pointers to functions to
!    save and restore machine-specific data,
!    in push_function_context and pop_function_context.  */
  void (*init_machine_status) PARAMS ((struct function *));
- void (*save_machine_status) PARAMS ((struct function *));
- void (*restore_machine_status) PARAMS ((struct function *));
- void (*mark_machine_status) PARAMS ((struct function *));
  void (*free_machine_status) PARAMS ((struct function *));
  
  /* Likewise, but for language-specific data.  */
  void (*init_lang_status) PARAMS ((struct function *));
--- 129,142 ----
     assign_stack_local uses frame_pointer_rtx when this is nonzero.  */
  static int virtuals_instantiated;
  
! /* These variables hold pointers to functions to create and destroy
!    target specific, per-function data structures.  */
  void (*init_machine_status) PARAMS ((struct function *));
  void (*free_machine_status) PARAMS ((struct function *));
+ /* This variable holds a pointer to a function to register any
+    data items in the target specific, per-function data structure
+    that will need garbage collection.  */
+ void (*mark_machine_status) PARAMS ((struct function *));
  
  /* Likewise, but for language-specific data.  */
  void (*init_lang_status) PARAMS ((struct function *));
*************** push_function_context_to (context)
*** 358,365 ****
  
    if (save_lang_status)
      (*save_lang_status) (p);
-   if (save_machine_status)
-     (*save_machine_status) (p);
  
    cfun = 0;
  }
--- 358,363 ----
*************** pop_function_context_from (context)
*** 389,396 ****
  
    restore_emit_status (p);
  
-   if (restore_machine_status)
-     (*restore_machine_status) (p);
    if (restore_lang_status)
      (*restore_lang_status) (p);
  
--- 387,392 ----

Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/emit-rtl.c,v
retrieving revision 1.159
diff -p -r1.159 emit-rtl.c
*** emit-rtl.c	2001/01/05 15:34:38	1.159
--- emit-rtl.c	2001/01/10 19:40:35
*************** init_emit_once (line_numbers)
*** 4080,4088 ****
    ggc_add_rtx_root (global_rtl, GR_MAX);
  
  #ifdef INIT_EXPANDERS
!   /* This is to initialize save_machine_status and restore_machine_status before
!      the first call to push_function_context_to.  This is needed by the Chill
!      front end which calls push_function_context_to before the first cal to
       init_function_start.  */
    INIT_EXPANDERS;
  #endif
--- 4080,4088 ----
    ggc_add_rtx_root (global_rtl, GR_MAX);
  
  #ifdef INIT_EXPANDERS
!   /* This is to initialize {init|mark|free}_machine_status before the first
!      call to push_function_context_to.  This is needed by the Chill front
!      end which calls push_function_context_to before the first cal to
       init_function_start.  */
    INIT_EXPANDERS;
  #endif

Index: tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tm.texi,v
retrieving revision 1.162
diff -p -r1.162 tm.texi
*** tm.texi	2001/01/05 07:38:47	1.162
--- tm.texi	2001/01/10 19:40:36
*************** includes @file{tm.h} and most compiler s
*** 22,27 ****
--- 22,28 ----
  @menu
  * Driver::              Controlling how the driver runs the compilation passes.
  * Run-time Target::     Defining @samp{-m} options like @samp{-m68000} and @samp{-m68020}.
+ * Per-Function Data::   Defining data structures for per-function information.
  * Storage Layout::      Defining sizes and alignments of data.
  * Type Layout::         Defining sizes and properties of basic user data types.
  * Registers::           Naming and describing the hardware registers.
*************** generated code.
*** 702,707 ****
--- 703,782 ----
  Define this macro if debugging can be performed even without a frame
  pointer.  If this macro is defined, GCC will turn on the
  @samp{-fomit-frame-pointer} option whenever @samp{-O} is specified.
+ @end table
+ 
+ @node Per-Function Data
+ @section Defining data structures for per-function information.
+ @cindex per-function data
+ @cindex data structures
+ 
+ If the target needs to store information on a per-function basis, GCC
+ provides a macro and a couple of variables to allow this.  Note, just
+ using statics to store the information is a bad idea, since GCC supports
+ nested functions, so you can be halfway through encoding one function
+ when another one comes along.
+ 
+ GCC defines a data structure called @code{struct function} which
+ contains all of the data specific to an individual function.  This
+ structure contains a field called @code{machine} whose type is
+ @code{struct machine_function *}, which can be used by targets to point
+ to their own specific data.
+ 
+ If a target needs per-function specific data it should define the type
+ @code{struct machine_function} and also the macro
+ @code{INIT_EXPANDERS}.  This macro should be used to initialise some or
+ all of the function pointers @code{init_machine_status},
+ @code{free_machine_status} and @code{mark_machine_status}.  These
+ pointers are explained below. 
+ 
+ One typical use of per-function, target specific data is to create an
+ RTX to hold the register containing the function's return address.  This
+ RTX can then be used to implement the @code{__builtin_return_address}
+ function, for level 0.
+ 
+ Note - earlier implementations of GCC used a single data area to hold
+ all of the per-function information.  Thus when processing of a nested
+ function began the old per-function data had to be pushed onto a
+ stack, and when the processing was finished, it had to be popped off the
+ stack.  GCC used to provide function pointers called
+ @code{save_machine_status} and @code{restore_machine_status} to handle 
+ the saving and restoring of the target specific information.  Since the
+ single data area approach is no longer used, these pointers are no
+ longer supported.
+ 
+ The macro and function pointers are described below.
+ 
+ @table @code
+ @findex INIT_EXPANDERS
+ @item   INIT_EXPANDERS
+ Macro called to initialise any target specific information.  This macro
+ is called once per function, before generation of any RTL has begun.
+ The intention of this macro is to allow the initialisation of the
+ function pointers below.
+ 
+ @findex init_machine_status
+ @item   init_machine_status
+ This is a @code{void (*)(struct function *)} function pointer.  If this
+ pointer is non-NULL it will be called once per function, before function
+ compilation starts, in order to allow the target to perform any target
+ specific initialisation of the @code{struct function} structure.  It is
+ intended that this would be used to initialise the @code{machine} of
+ that struture.
+ 
+ @findex free_machine_status
+ @item   free_machine_status
+ This is a @code{void (*)(struct function *)} function pointer.  If this
+ pointer is non-NULL it will be called once per function, after the
+ function has been compiled, in order to allow any memory allocated
+ during the @code{init_machine_status} function call to be freed.
+ 
+ @findex mark_machine_status
+ @item   mark_machine_status
+ This is a @code{void (*)(struct function *)} function pointer.  If this
+ pointer is non-NULL it will be called once per function in order to mark
+ any data items in the @code{struct machine_function} structure which
+ need garbage collection.
+ 
  @end table
  
  @node Storage Layout

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]