Patch to allow targets to prevent inlining

Nick Clifton nickc@cygnus.com
Mon Apr 24 11:12:00 GMT 2000


Hi Guys,

  Here is a revised version of the patch to allow targets to decide if
  a function with a target specific attribute can be inlined.  This
  time the target macro is a boolean function, so the target code does
  not have to return an (internationalised) text string.

  OK to apply ?

Cheers
	Nick

2000-04-24  Nick Clifton  <nickc@cygnus.com>

	* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): If not
	defined, define to return zero.
	(function_cannot_inline_p): If a function has any target
	specific attributes, then use the macro
	FUNCTION_ATTRIBUTE_INLINABLE_P to allow the target to decide
	whether it can be inlined.  If it cannot, issue a suitable
	explanation.

	* tm.texi: Add a new node 'Inlining' to document the new macro
	FUNCTION_ATTRIBUTE_INLINABLE_P. 

Index: gcc/integrate.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/integrate.c,v
retrieving revision 1.101
diff -p -r1.101 integrate.c
*** integrate.c	2000/04/21 19:32:10	1.101
--- integrate.c	2000/04/24 18:08:36
*************** extern struct obstack *function_maybeper
*** 62,67 ****
--- 62,73 ----
     ? (1 + (3 * list_length (DECL_ARGUMENTS (DECL))) / 2) \
     : (8 * (8 + list_length (DECL_ARGUMENTS (DECL)))))
  #endif
+ 
+ /* Decide whether a function with a target specific attribute 
+    attached can be inlined.  By default we disallow this.  */
+ #ifndef FUNCTION_ATTRIBUTE_INLINABLE_P
+ #define FUNCTION_ATTRIBUTE_INLINABLE_P(FNDECL) 0
+ #endif
  
  static rtvec initialize_for_inline	PARAMS ((tree));
  static void note_modified_parmregs	PARAMS ((rtx, rtx, void *));
*************** function_cannot_inline_p (fndecl)
*** 239,246 ****
    result = DECL_RTL (DECL_RESULT (fndecl));
    if (result && GET_CODE (result) == PARALLEL)
      return N_("inline functions not supported for this return value type");
  
!   return 0;
  }
  
  /* Map pseudo reg number into the PARM_DECL for the parm living in the reg.
--- 245,259 ----
    result = DECL_RTL (DECL_RESULT (fndecl));
    if (result && GET_CODE (result) == PARALLEL)
      return N_("inline functions not supported for this return value type");
+ 
+   /* If the function has a target specific attribute attached to it,
+      then we assume that we should not inline it.  This can be overriden
+      by the target if it defines FUNCTION_ATTRIBUTE_INLINABLE_P.  */
+   if (DECL_MACHINE_ATTRIBUTES (fndecl)
+       && ! FUNCTION_ATTRIBUTE_INLINABLE_P (fndecl))
+     return N_("function with target specific attribute(s) cannot be inlined");
  
!   return NULL;
  }
  
  /* Map pseudo reg number into the PARM_DECL for the parm living in the reg.

Index: gcc/tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tm.texi,v
retrieving revision 1.122
diff -p -r1.122 tm.texi
*** tm.texi	2000/04/07 09:24:45	1.122
--- tm.texi	2000/04/24 18:08:37
*************** This describes the stack layout and call
*** 2169,2174 ****
--- 2169,2175 ----
  * Caller Saves::
  * Function Entry::
  * Profiling::
+ * Inlining::
  @end menu
  
  @node Frame Layout
*************** Registers or condition codes clobbered b
*** 3670,3675 ****
--- 3671,3687 ----
  A C function or functions which are needed in the library to
  support block profiling.
  @end table
+ 
+ @node Inlining
+ @subsection Permitting inlining of functions with attributes
+ @cindex inlining
+ 
+ By default if a function has a target specific attribute attached to it,
+ it will not be inlined.  This behaviour can be overridden if the target
+ defines the @samp{FUNCTION_ATTRIBUTE_INLINABLE_P} macro.  This macro
+ takes one argument, a @samp{DECL} describing the function.  It should
+ return non-zero if the function can be inlined, otherwise it should
+ return 0.
  
  @node Varargs
  @section Implementing the Varargs Macros


More information about the Gcc-patches mailing list