Subject: egcs revisited
To: None <port-arm32@netbsd.org>
From: Charles M. Hannum <root@ihack.net>
List: port-arm32
Date: 11/15/1998 15:15:55
So, with a small change to fix a bug that I mentioned to Richard
Earnshaw (by reverting some code to its state in 2.7), egcs 1.1.1pre2
does seem to work on the ARM.

Now we just need to sort out the gas.new and ld issues...


Index: arm.c
===================================================================
RCS file: /cvsroot/src/gnu/dist/gcc/config/arm/arm.c,v
retrieving revision 1.9
diff -c -2 -r1.9 arm.c
*** arm.c	1998/11/14 04:27:17	1.9
--- arm.c	1998/11/15 20:10:09
***************
*** 214,217 ****
--- 214,227 ----
  };
  
+ int
+ arm_preserved_register (regno)
+      int regno;
+ {
+   if (flag_pic && regno == PIC_OFFSET_TABLE_REGNUM)
+     return 1;
+        
+   return ! call_used_regs[regno];
+ }
+ 
  /* Fix up any incompatible options that the user has specified.
     This has now turned into a maze.  */
***************
*** 377,381 ****
    if (TARGET_THUMB_INTERWORK)
      for (regno = 0; regno < 16; regno++)
!       if (regs_ever_live[regno] && ! call_used_regs[regno])
  	return 0;
        
--- 387,391 ----
    if (TARGET_THUMB_INTERWORK)
      for (regno = 0; regno < 16; regno++)
!       if (regs_ever_live[regno] && arm_preserved_register (regno))
  	return 0;
        
***************
*** 383,387 ****
       requires an insn */
    for (regno = 16; regno < 24; regno++)
!     if (regs_ever_live[regno] && ! call_used_regs[regno])
        return 0;
  
--- 393,397 ----
       requires an insn */
    for (regno = 16; regno < 24; regno++)
!     if (regs_ever_live[regno] && arm_preserved_register (regno))
        return 0;
  
***************
*** 4750,4754 ****
      
    for (reg = 0; reg <= 10; reg++)
!     if (regs_ever_live[reg] && ! call_used_regs[reg])
        live_regs++;
  
--- 4760,4764 ----
      
    for (reg = 0; reg <= 10; reg++)
!     if (regs_ever_live[reg] && arm_preserved_register (reg))
        live_regs++;
  
***************
*** 4772,4776 ****
  
        for (reg = 0; reg <= 10; reg++)
!         if (regs_ever_live[reg] && ! call_used_regs[reg])
            {
  	    strcat (instr, "%|");
--- 4782,4786 ----
  
        for (reg = 0; reg <= 10; reg++)
!         if (regs_ever_live[reg] && arm_preserved_register (reg))
            {
  	    strcat (instr, "%|");
***************
*** 4869,4873 ****
  
    for (reg = 0; reg <= 10; reg++)
!     if (regs_ever_live[reg] && ! call_used_regs[reg])
        live_regs_mask |= (1 << reg);
  
--- 4879,4883 ----
  
    for (reg = 0; reg <= 10; reg++)
!     if (regs_ever_live[reg] && arm_preserved_register (reg))
        live_regs_mask |= (1 << reg);
  
***************
*** 4941,4945 ****
  
    for (reg = 0; reg <= 10; reg++)
!     if (regs_ever_live[reg] && ! call_used_regs[reg])
        {
          live_regs_mask |= (1 << reg);
--- 4951,4955 ----
  
    for (reg = 0; reg <= 10; reg++)
!     if (regs_ever_live[reg] && arm_preserved_register (reg))
        {
          live_regs_mask |= (1 << reg);
***************
*** 4952,4956 ****
  	{
  	  for (reg = 23; reg > 15; reg--)
! 	    if (regs_ever_live[reg] && ! call_used_regs[reg])
  	      {
  		floats_offset += 12;
--- 4962,4966 ----
  	{
  	  for (reg = 23; reg > 15; reg--)
! 	    if (regs_ever_live[reg] && arm_preserved_register (reg))
  	      {
  		floats_offset += 12;
***************
*** 4965,4969 ****
  	  for (reg = 23; reg > 15; reg--)
  	    {
! 	      if (regs_ever_live[reg] && ! call_used_regs[reg])
  		{
  		  floats_offset += 12;
--- 4975,4979 ----
  	  for (reg = 23; reg > 15; reg--)
  	    {
! 	      if (regs_ever_live[reg] && arm_preserved_register (reg))
  		{
  		  floats_offset += 12;
***************
*** 5022,5026 ****
  	{
  	  for (reg = 16; reg < 24; reg++)
! 	    if (regs_ever_live[reg] && ! call_used_regs[reg])
  	      fprintf (f, "\tldfe\t%s%s, [%ssp], #12\n", REGISTER_PREFIX,
  		       reg_names[reg], REGISTER_PREFIX);
--- 5032,5036 ----
  	{
  	  for (reg = 16; reg < 24; reg++)
! 	    if (regs_ever_live[reg] && arm_preserved_register (reg))
  	      fprintf (f, "\tldfe\t%s%s, [%ssp], #12\n", REGISTER_PREFIX,
  		       reg_names[reg], REGISTER_PREFIX);
***************
*** 5032,5036 ****
  	  for (reg = 16; reg < 24; reg++)
  	    {
! 	      if (regs_ever_live[reg] && ! call_used_regs[reg])
  		{
  		  if (reg - start_reg == 3)
--- 5042,5046 ----
  	  for (reg = 16; reg < 24; reg++)
  	    {
! 	      if (regs_ever_live[reg] && arm_preserved_register (reg))
  		{
  		  if (reg - start_reg == 3)
***************
*** 5202,5206 ****
    if (! volatile_func)
      for (reg = 0; reg <= 10; reg++)
!       if (regs_ever_live[reg] && ! call_used_regs[reg])
  	live_regs_mask |= 1 << reg;
  
--- 5212,5216 ----
    if (! volatile_func)
      for (reg = 0; reg <= 10; reg++)
!       if (regs_ever_live[reg] && arm_preserved_register (reg))
  	live_regs_mask |= 1 << reg;
  
***************
*** 5240,5244 ****
  	{
  	  for (reg = 23; reg > 15; reg--)
! 	    if (regs_ever_live[reg] && ! call_used_regs[reg])
  	      emit_insn (gen_rtx (SET, VOIDmode, 
  				  gen_rtx (MEM, XFmode, 
--- 5250,5254 ----
  	{
  	  for (reg = 23; reg > 15; reg--)
! 	    if (regs_ever_live[reg] && arm_preserved_register (reg))
  	      emit_insn (gen_rtx (SET, VOIDmode, 
  				  gen_rtx (MEM, XFmode, 
***************
*** 5253,5257 ****
  	  for (reg = 23; reg > 15; reg--)
  	    {
! 	      if (regs_ever_live[reg] && ! call_used_regs[reg])
  		{
  		  if (start_reg - reg == 3)
--- 5263,5267 ----
  	  for (reg = 23; reg > 15; reg--)
  	    {
! 	      if (regs_ever_live[reg] && arm_preserved_register (reg))
  		{
  		  if (start_reg - reg == 3)
Index: arm.h
===================================================================
RCS file: /cvsroot/src/gnu/dist/gcc/config/arm/arm.h,v
retrieving revision 1.7
diff -c -2 -r1.7 arm.h
*** arm.h	1998/08/24 18:32:22	1.7
--- arm.h	1998/11/15 20:10:10
***************
*** 679,683 ****
      {							\
        fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1;		\
!       call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 0;	\
      }							\
  }
--- 679,683 ----
      {							\
        fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1;		\
!       call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;	\
      }							\
  }
***************
*** 1183,1190 ****
          {								\
            for (regno = 0; regno <= 10; regno++)				\
! 	    if (regs_ever_live[regno] && ! call_used_regs[regno])	\
  	      saved_hard_reg = 1, offset += 4;				\
            for (regno = 16; regno <=23; regno++)				\
! 	    if (regs_ever_live[regno] && ! call_used_regs[regno])	\
  	      offset += 12;						\
  	}								\
--- 1183,1190 ----
          {								\
            for (regno = 0; regno <= 10; regno++)				\
! 	    if (regs_ever_live[regno] && arm_preserved_register (regno))\
  	      saved_hard_reg = 1, offset += 4;				\
            for (regno = 16; regno <=23; regno++)				\
! 	    if (regs_ever_live[regno] && arm_preserved_register (regno))\
  	      offset += 12;						\
  	}								\
***************
*** 2014,2017 ****
--- 2014,2018 ----
     fully defined yet.  */
  
+ int arm_preserved_register (/* int */);
  void arm_override_options (/* void */);
  int use_return_insn (/* void */);