New target macro HARD_REGNO_CALL_PART_CLOBBERED

Michael Hayes m.hayes@elec.canterbury.ac.nz
Tue Sep 29 02:46:00 GMT 1998


This target macro is used by the register allocator to prevent
allocation of certain modes in registers which may be clobbered by a
call.  Currently, GCC assumes if a hard register is not a
call_used_register, then it is fully preserved across a call.  This is
not true with the ABI used by the C4x target, where some registers are
only partially preserved across a call.

This patch has no effect on existing targets.

Sun Sep 27 10:25:18 1998  Michael Hayes  <m.hayes@elec.canterbury.ac.nz>

	* regs.h (HARD_REGNO_CALL_PART_CLOBBERED):  New macro.
	* local-alloc.c (find_free_reg): Use it.
	* global.c (find_reg): Likewise.
	
Index: regs.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/regs.h,v
retrieving revision 1.4
diff -c -p -r1.4 regs.h
*** regs.h	1998/07/02 13:49:32	1.4
--- regs.h	1998/09/29 09:25:24
*************** extern int caller_save_needed;
*** 211,216 ****
--- 211,222 ----
  #define CLASS_LIKELY_SPILLED_P(CLASS) (reg_class_size[(int) (CLASS)] == 1)
  #endif
  
+ /* Registers that get partially clobbered by a call in a given mode. 
+    These must not be call used registers.  */
+ #ifndef HARD_REGNO_CALL_PART_CLOBBERED
+ #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE) 0
+ #endif
+ 
  /* Allocated in local_alloc.  */
  
  /* A list of SCRATCH rtl allocated by local-alloc.  */
Index: global.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/global.c,v
retrieving revision 1.14
diff -c -p -r1.14 global.c
*** global.c	1998/09/16 00:31:21	1.14
--- global.c	1998/09/29 09:25:39
*************** find_reg (allocno, losers, alt_regs_p, a
*** 976,982 ****
  	  int regno = i;
  #endif
  	  if (! TEST_HARD_REG_BIT (used, regno)
! 	      && HARD_REGNO_MODE_OK (regno, mode))
  	    {
  	      register int j;
  	      register int lim = regno + HARD_REGNO_NREGS (regno, mode);
--- 976,985 ----
  	  int regno = i;
  #endif
  	  if (! TEST_HARD_REG_BIT (used, regno)
! 	      && HARD_REGNO_MODE_OK (regno, mode)
! 	      && (allocno_calls_crossed[allocno] == 0
! 		  || accept_call_clobbered
! 		  || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
  	    {
  	      register int j;
  	      register int lim = regno + HARD_REGNO_NREGS (regno, mode);
Index: local-alloc.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/local-alloc.c,v
retrieving revision 1.19
diff -c -p -r1.19 local-alloc.c
*** local-alloc.c	1998/09/08 00:29:35	1.19
--- local-alloc.c	1998/09/29 09:25:55
*************** find_free_reg (class, mode, qty, accept_
*** 2043,2049 ****
        int regno = i;
  #endif
        if (! TEST_HARD_REG_BIT (first_used, regno)
! 	  && HARD_REGNO_MODE_OK (regno, mode))
  	{
  	  register int j;
  	  register int size1 = HARD_REGNO_NREGS (regno, mode);
--- 2043,2052 ----
        int regno = i;
  #endif
        if (! TEST_HARD_REG_BIT (first_used, regno)
! 	  && HARD_REGNO_MODE_OK (regno, mode)
! 	  && (qty_n_calls_crossed[qty] == 0
! 	      || accept_call_clobbered
! 	      || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
  	{
  	  register int j;
  	  register int size1 = HARD_REGNO_NREGS (regno, mode);
Index: tm.texi
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/tm.texi,v
retrieving revision 1.50
diff -c -p -r1.50 tm.texi
*** tm.texi	1998/09/15 19:19:00	1.50
--- tm.texi	1998/09/29 09:26:37
*************** If a register has 0 in @code{CALL_USED_R
*** 1333,1338 ****
--- 1333,1349 ----
  automatically saves it on function entry and restores it on function
  exit, if the register is used within the function.
  
+ @findex HARD_REGNO_CALL_PART_CLOBBERED
+ @item HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode})
+ @cindex call-used register
+ @cindex call-clobbered register
+ @cindex call-saved register
+ A C expression that is non-zero if it is not permissible to store a
+ value of mode @var{mode} in hard register number @var{regno} across a
+ call without some part of it being clobbered.  For most machines this
+ macro need not be defined.  It is only required for machines that do not
+ preserve the entire contents of a register across a call.
+ 
  @findex CONDITIONAL_REGISTER_USAGE
  @findex fixed_regs
  @findex call_used_regs



More information about the Gcc-patches mailing list