This is the mail archive of the gcc-bugs@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]

Re: flow patch for building ia64


>> On Mon, Jul 30, 2001 at 09:14:22AM -0700, amacleod@cygnus.com wrote:
>> > Which of the magic pseudos should be clear? 
>> > 
>> >     /*FP RA CCV UNAT PFS LC EC */
>> 
>> CCV, PFS, and UNAT are call used; SP FP RA LC EC are call saved.

Hmm, that causes another problem, which I'll describe in a minute.

>> > + #ifdef CALL_REALLY_USED_REGISTERS
>> > + static char call_really_used_regs[] = CALL_REALLY_USED_REGISTERS;
>> > + #endif
>> 
>> Suggest you always define this array, falling back to call_used
>> registers.  Also, -fcall-used will need to modify this, so it
>> can't be static.

Can do.


OK. The new problem is with ar.pfs and sibcalls.

I have a single basic block function with a couple of calls in
it to fprintf. The last one is turned into a sibcall, and both
PFS and b0 are restored before the sibcall:

(insn 97 52 99 (set (reg:DI 332 ar.pfs)
        (reg:DI 35 r39)) -1 (nil)
    (nil))

(insn 99 97 100 (set (reg:DI 320 b0)
        (reg:DI 34 r38)) -1 (nil)
    (nil))

(insn 100 99 59 (parallel[
            (set (reg:DI 2 r2)
                (unspec_volatile:DI[
                        (const_int 0 [0x0])
                    ]  0))
            (use (const_int 0 [0x0]))
            (use (const_int 0 [0x0]))
            (use (const_int 4 [0x4]))
            (use (const_int 0 [0x0]))
        ] ) -1 (nil)
    (nil))

(call_insn/j 59 100 60 (parallel[
            (call (mem:DI (symbol_ref/v:DI ("fwrite")) 0)
                (const_int 4 [0x4]))
            (use (unspec[
                        (reg:DI 1 r1)
                    ]  9))
            (use (reg:DI 320 b0))
        ] ) 215 {sibcall_pic} (insn_list:REG_DEP_ANTI 84 (insn_list:REG_DEP_ANTI 85 (insn_list:REG_DEP_ANTI 86 (insn_list:REG_DEP_ANTI 87 (insn_list:REG_DEP_ANTI 39 (insn_list 54 (insn_list 56 (insn_list 58 (insn_list:REG_DEP_ANTI 89 (insn_list 52 (insn_list:REG_DEP_ANTI 37 (insn_list:REG_DEP_ANTI 35 (insn_list:REG_DEP_ANTI 33 (insn_list:REG_DEP_ANTI 31 (insn_list 42 (insn_list:REG_DEP_ANTI 88 (nil)))))))))))))))))
    (nil)
    (expr_list (use (reg:DI 115 r35))
        (expr_list (use (reg:DI 114 r34))
            (expr_list (use (reg:DI 113 r33))
                (expr_list (use (reg:DI 112 r32))
                    (nil))))))




The sibcall marks b0 as used, but with no mention of ar.pfs, it ending 
the basic block, and ar.pfs clobbered by the call, flow tries to
remove insn 97 because it is not needed.

So it appears that I should do the same thing with ar.pfs on a sibcall
as we do with b0, mark it as used? And then does that mean I should
do that with CCVS and UNAT too?

Anyway, none of that shows up until you apply this patch
which will get you that far :-)


So does this patch look OK?

Andrew



	* regclass.c (call_really_used_regs): New array for registers which
	are actually used by a call.
	(init_reg_sets_1): Initialize regs_invalidated_by_call with the
	new array.
	(fix_register): Set call_really_used too.
	* config/ia64/ia64.h (CALL_REALLY_USED_REGISTERS): Initialize.
	* doc/tm.texi (CALL_REALLY_USED_REGISTERS): Document.

Index: gcc/regclass.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/regclass.c,v
retrieving revision 1.124
diff -c -p -r1.124 regclass.c
*** regclass.c	2001/07/20 16:55:03	1.124
--- regclass.c	2001/07/31 14:48:37
*************** HARD_REG_SET losing_caller_save_reg_set;
*** 94,99 ****
--- 94,111 ----
  /* Data for initializing the above.  */
  
  static char initial_call_used_regs[] = CALL_USED_REGISTERS;
+ 
+ /* This is much like call_used_regs, except it doesn't have to
+    be a superset of FIXED_REGISTERS. This vector indicates
+    what is really call clobbered, and is used when defining 
+    regs_invalidated_by_call.  */
+ 
+ char call_really_used_regs[] = 
+ #ifdef CALL_REALLY_USED_REGISTERS
+ 				CALL_REALLY_USED_REGISTERS;
+ #else
+ 				CALL_USED_REGISTERS;
+ #endif
    
  /* Indexed by hard register number, contains 1 for registers that are
     fixed use or call used registers that cannot hold quantities across
*************** init_reg_sets_1 ()
*** 464,470 ****
        else if (i == PIC_OFFSET_TABLE_REGNUM && flag_pic)
  	;
  #endif
!       else if (call_used_regs[i] || global_regs[i])
  	SET_HARD_REG_BIT (regs_invalidated_by_call, i);
      }
  
--- 476,482 ----
        else if (i == PIC_OFFSET_TABLE_REGNUM && flag_pic)
  	;
  #endif
!       else if (call_really_used_regs[i] || global_regs[i])
  	SET_HARD_REG_BIT (regs_invalidated_by_call, i);
      }
  
*************** fix_register (name, fixed, call_used)
*** 747,752 ****
--- 759,766 ----
  	{
  	  fixed_regs[i] = fixed;
  	  call_used_regs[i] = call_used;
+ 	  if (fixed == 0)
+ 	    call_really_used_regs[i] = call_used;
  	}
      }
    else
Index: gcc/config/ia64/ia64.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/ia64/ia64.h,v
retrieving revision 1.78
diff -c -p -r1.78 ia64.h
*** ia64.h	2001/07/25 13:21:49	1.78
--- ia64.h	2001/07/31 14:48:47
*************** while (0)
*** 633,638 ****
--- 633,677 ----
       1, 1,  1,   1,  1, 0, 1				\
  }
  
+ /* Like `CALL_USED_REGISTERS' but used to overcome a historical 
+    problem which makes CALL_USED_REGISTERS *always* include
+    all the FIXED_REGISTERS. Until this problem has been 
+    resolved this macro can be used to overcome this situation.
+    In particular, block_propagate() requires this list 
+    be acurate, or we can remove registers which should be live.  
+    This macro is used in regs_invalidated_by_call ()*/
+ 
+ #define CALL_REALLY_USED_REGISTERS \
+ { /* General registers.  */				\
+   1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1,	\
+   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,	\
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	\
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	\
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	\
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	\
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	\
+   0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,	\
+   /* Floating-point registers.  */			\
+   1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,	\
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	\
+   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,	\
+   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,	\
+   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,	\
+   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,	\
+   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,	\
+   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,	\
+   /* Predicate registers.  */				\
+   1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,	\
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	\
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	\
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	\
+   /* Branch registers.  */				\
+   1, 0, 0, 0, 0, 0, 1, 1,				\
+   /*FP RA CCV UNAT PFS LC EC */				\
+      0, 0,  1,   1,  1, 0, 0				\
+ }
+ 
+ 
  /* Define this macro if the target machine has register windows.  This C
     expression returns the register number as seen by the called function
     corresponding to the register number OUT as seen by the calling function.
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/doc/tm.texi,v
retrieving revision 1.39
diff -c -p -r1.39 tm.texi
*** tm.texi	2001/07/23 20:33:40	1.39
--- tm.texi	2001/08/01 13:35:14
*************** If a register has 0 in @code{CALL_USED_R
*** 1700,1705 ****
--- 1700,1715 ----
  automatically saves it on function entry and restores it on function
  exit, if the register is used within the function.
  
+ @findex CALL_REALLY_USED_REGISTERS
+ @item CALL_REALLY_USED_REGISTERS
+ @cindex call-used register
+ @cindex call-clobbered register
+ @cindex call-saved register
+ Like @code{CALL_USED_REGISTERS} except this macro doesn't require 
+ that the entire set of FIXED_REGISTERS be included.  (CALL_USED_REGISTERS
+ must be a superset of FIXED_REGISTERS).  This macro is optional.  
+ If not specified, it defaults to the value of CALL_USED_REGISTERS.
+ 
  @findex HARD_REGNO_CALL_PART_CLOBBERED
  @item HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode})
  @cindex call-used register


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