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]
Other format: [Raw text]

PATCH: per-function reset hooks


This is part 2 of the 3-part patch set that allows selecting mips16/nomips16 mode on a per-function basis. I've split this out from the rest of the non-MIPS-specific part because, as I've posted in another message, this no longer really seems like the right place to be doing the back end reinitialization. I'm reposting it primarily for completeness so that the current patch state is preserved in the mailing list archives. :-)

-Sandra

2007-07-10  Sandra Loosemore  <sandra@codesourcery.com>
	    David Ung  <davidu@mips.com>
            Nigel Stephens <nigel@mips.com>

	gcc/
	Add target hooks invoked when starting RTL code generation for
	each function.

	* target-def.h (TARGET_PREPARE_FUNCTION_START): Define.
	(TARGET_END_OF_FILE_CLEANUP): Define
	(TARGET_INITIALIZER):  Add entries for above symbols.
	* target.h (struct gcc_target):  Add prepare_function_start
	and end_of_file_cleanup slots.
	* doc/tm.texi (TARGET_PREPARE_FUNCTION_START): Document.
	(TARGET_END_OF_FILE_CLEANUP): Likewise.
	* function.c (prepare_function_start): Invoke prepare_function_start
	target hook.
	* toplev.c (compile_file): Invoke end_of_file_cleanup target hook.
Index: gcc/target-def.h
===================================================================
*** gcc/target-def.h	(revision 127325)
--- gcc/target-def.h	(working copy)
***************
*** 471,476 ****
--- 471,484 ----
  #define TARGET_MANGLE_TYPE hook_constcharptr_tree_null
  #define TARGET_ALLOCATE_INITIAL_VALUE NULL
  
+ #ifndef TARGET_PREPARE_FUNCTION_START
+ #define TARGET_PREPARE_FUNCTION_START hook_void_tree
+ #endif
+ 
+ #ifndef TARGET_END_OF_FILE_CLEANUP
+ #define TARGET_END_OF_FILE_CLEANUP hook_void_void
+ #endif
+ 
  #ifndef TARGET_INIT_LIBFUNCS
  #define TARGET_INIT_LIBFUNCS hook_void_void
  #endif
***************
*** 711,716 ****
--- 719,726 ----
    TARGET_MAX_ANCHOR_OFFSET,			\
    TARGET_USE_ANCHORS_FOR_SYMBOL_P,		\
    TARGET_FUNCTION_OK_FOR_SIBCALL,		\
+   TARGET_PREPARE_FUNCTION_START,		\
+   TARGET_END_OF_FILE_CLEANUP,			\
    TARGET_IN_SMALL_DATA_P,			\
    TARGET_BINDS_LOCAL_P,				\
    TARGET_MANGLE_DECL_ASSEMBLER_NAME,		\
Index: gcc/target.h
===================================================================
*** gcc/target.h	(revision 127325)
--- gcc/target.h	(working copy)
*************** struct gcc_target
*** 560,565 ****
--- 560,571 ----
       this is an indirect call.  */
    bool (*function_ok_for_sibcall) (tree decl, tree exp);
  
+   /* Prepare for function RTL generation.  */
+   void (* prepare_function_start) (tree);
+ 
+   /* Start RTL generation for cleanup at end of file.  */
+   void (* end_of_file_cleanup) (void);
+ 
    /* True if EXP should be placed in a "small data" section.  */
    bool (* in_small_data_p) (tree);
  
Index: gcc/doc/tm.texi
===================================================================
*** gcc/doc/tm.texi	(revision 127325)
--- gcc/doc/tm.texi	(working copy)
*************** The default value of this hook is @code{
*** 10103,10108 ****
--- 10103,10124 ----
  allocation.
  @end deftypefn
  
+ @deftypefn {Target Hook} void TARGET_PREPARE_FUNCTION_START (tree @var{decl})
+ The compiler invokes this hook as its first action in preparing to emit code
+ for the function declared by @var{decl}.  You can define this function if
+ the back end needs to perform any initialization or reset actions on a
+ per-function basis.  The default hook function does nothing.
+ @end deftypefn
+ 
+ @deftypefn {Target Hook} void TARGET_END_OF_FILE_CLEANUP (void)
+ The compiler invokes this hook after code generation for the last function 
+ in the file has been completed, but before writing deferred declarations,
+ constants, debug information, and the like.  If your back end uses
+ @code{TARGET_PREPARE_FUNCTION_START} to perform per-function reset
+ actions, it may also need to define this hook to clean up after the
+ last function.  The default hook function does nothing.
+ @end deftypefn
+ 
  @defmac TARGET_OBJECT_SUFFIX
  Define this macro to be a C string representing the suffix for object
  files on your target machine.  If you do not define this macro, GCC will
Index: gcc/function.c
===================================================================
*** gcc/function.c	(revision 127325)
--- gcc/function.c	(working copy)
*************** allocate_struct_function (tree fndecl)
*** 3847,3852 ****
--- 3847,3855 ----
  static void
  prepare_function_start (tree fndecl)
  {
+   if (fndecl)
+     (*targetm.prepare_function_start) (fndecl);
+ 
    if (fndecl && DECL_STRUCT_FUNCTION (fndecl))
      cfun = DECL_STRUCT_FUNCTION (fndecl);
    else
Index: gcc/toplev.c
===================================================================
*** gcc/toplev.c	(revision 127325)
--- gcc/toplev.c	(working copy)
*************** compile_file (void)
*** 1053,1058 ****
--- 1053,1061 ----
    if (flag_syntax_only)
      return;
  
+   /* Tell the back end we've finished with processing functions.  */
+   targetm.end_of_file_cleanup ();
+ 
    lang_hooks.decls.final_write_globals ();
  
    if (errorcount || sorrycount)

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