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]

Re: Bootstrap failure with thunks change + patch to fix it.


On Mon, Oct 21, 2002 at 09:00:43PM -0700, Mark Mitchell wrote:
> We'll have to ask the RS6000 maintainers to figure out what they want
> to do to fix this.  4-gigabyte objects -- especially with virtual
> functions in subobjects beyond the 4-gigabyte boundary -- are probably
> pretty rare, but still...

This part is easy to fix.  Something along the lines of the following
untested patch should do the trick.  I'm more concerned just how the
toc register gets loaded for ABI_AIX, TARGET_MINIMAL_TOC when there's
no constant pool for the function.  Methinks it doesn't.

Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.393
diff -c -p -r1.393 rs6000.c
*** gcc/config/rs6000/rs6000.c	21 Oct 2002 21:56:40 -0000	1.393
--- gcc/config/rs6000/rs6000.c	22 Oct 2002 11:32:02 -0000
*************** output_mi_thunk (file, thunk_fndecl, del
*** 11255,11294 ****
    const char *r12	 = reg_names[12];
    char buf[512];
    static int labelno = 0;
  
!   /* Small constants that can be done by one add instruction.  */
!   if (delta >= -32768 && delta <= 32767)
      {
        if (! TARGET_NEW_MNEMONICS)
! 	fprintf (file, "\tcal %s,%d(%s)\n", this_reg, (int) delta, this_reg);
        else
! 	fprintf (file, "\taddi %s,%s,%d\n", this_reg, this_reg, (int) delta);
      }
  
!   /* 64-bit constants.  If "int" is 32 bits, we'll never hit this abort.  */
!   else if (TARGET_64BIT && (delta < -2147483647 - 1 || delta > 2147483647))
!     abort ();
! 
!   /* Large constants that can be done by one addis instruction.  */
!   else if ((delta & 0xffff) == 0)
!     asm_fprintf (file, "\t{cau|addis} %s,%s,%d\n", this_reg, this_reg,
! 		 (int) (delta >> 16));
! 
!   /* 32-bit constants that can be done by an add and addis instruction.  */
!   else
      {
!       /* Break into two pieces, propagating the sign bit from the low
! 	 word to the upper word.  */
!       int delta_low  = ((delta & 0xffff) ^ 0x8000) - 0x8000;
!       int delta_high = (delta - delta_low) >> 16;
! 
!       asm_fprintf (file, "\t{cau|addis} %s,%s,%d\n", this_reg, this_reg,
! 		   delta_high);
  
!       if (! TARGET_NEW_MNEMONICS)
! 	fprintf (file, "\tcal %s,%d(%s)\n", this_reg, delta_low, this_reg);
        else
! 	fprintf (file, "\taddi %s,%s,%d\n", this_reg, this_reg, delta_low);
      }
  
    /* Get the prefix in front of the names.  */
--- 11255,11306 ----
    const char *r12	 = reg_names[12];
    char buf[512];
    static int labelno = 0;
+   HOST_WIDE_INT part;
  
!   part = delta & 0xffff;
!   if (part != 0)
      {
+       part = (part ^ 0x8000) - 0x8000;
+       delta -= part;
+ 
        if (! TARGET_NEW_MNEMONICS)
! 	fprintf (file, "\tcal %s,%d(%s)\n", this_reg, (int) part, this_reg);
        else
! 	fprintf (file, "\taddi %s,%s,%d\n", this_reg, this_reg, (int) part);
      }
  
!   part = (delta >> 16) & 0xffff;
!   if (part != 0)
      {
!       part = (part ^ 0x8000) - 0x8000;
!       delta -= part << 16;
!       asm_fprintf (file, "\t{cau|addis} %s,%s,%d\n",
! 		   this_reg, this_reg, (int) part);
!     }
  
!   if (TARGET_64BIT && delta != 0)
!     {
!       part = (delta >> 32) & 0xffff;
!       if (part != 0)
! 	{
! 	  part = (part ^ 0x8000) - 0x8000;
! 	  delta -= part << 32;
! 	  fprintf (file, "\tli %s,%d\n", r0, (int) part);
! 	  part = (delta >> 48) & 0xffff;
! 	  if (part != 0)
! 	    {
! 	      part = (part ^ 0x8000) - 0x8000;
! 	      fprintf (file, "\txoris %s,%s,%d\n", r0, r0, (int) part);
! 	    }
! 	}
        else
! 	{
! 	  part = (delta >> 48) & 0xffff;
! 	  part = (part ^ 0x8000) - 0x8000;
! 	  fprintf (file, "\tlis %s,%d\n", r0, (int) part);
! 	}
!       fprintf (file, "\tsldi %s,%s,32\n", r0, r0);
!       fprintf (file, "\tadd %s,%s,%s\n", this_reg, this_reg, r0);
      }
  
    /* Get the prefix in front of the names.  */

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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