[cft] excise gen_mem_addressof from ia64

Jim Wilson wilson@specifixinc.com
Tue Jul 6 02:19:00 GMT 2004


On Sun, 2004-07-04 at 20:40, Zack Weinberg wrote:
> Why does the union get TImode and not XFmode?

Because it is a union.  If a structure has a field which is the same
size as the struct, then we give the struct the mode of the field.  But
we do not do this for unions.  It isn't hard to see why, just because a
field is the same size as the union containing it does not mean that the
field is the only element of the struct.  If I had
union foo {
  long double ld;
  char c;
};
then the union is still the same size as the long double, but it makes
no sense to make it XFmode.  So for unions, instead of a size test, we
need a test that counts the number of FIELD_DECLs, and if there is only
one, and it has the same size as the union (no extra padding), then we
give the union the same mode as the field.  And since this may
accidentally change the calling conventions for some targets, we
probably need to do this conditionally via a macro.

See the code in compute_record_mode
     /* If this field is the whole struct, remember its mode so
         that, say, we can put a double in a class into a DF
         register instead of forcing it to live in the stack.  */
  /* If we only have one real field; use its mode.  This only applies to
     RECORD_TYPE.  This does not apply to unions.  */

I can make this work by modifying ia64_function_arg to return a PARRALEL
instead of a TImode FP REG when we have an XFmode HFA extracted from a
TImode argument.  This is simple and easy enough that there shouldn't be
any problems resulting from doing this.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
-------------- next part --------------
2004-07-05  James E Wilson  <wilson@specifixinc.com>

	* config/ia64/ia64.c (ia64_function_arg): For a single element HFA,
	do return a parallel if hfa_mode == XFmode and mode == TImode.

Index: ia64.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ia64/ia64.c,v
retrieving revision 1.292
diff -p -r1.292 ia64.c
*** ia64.c	16 Jun 2004 15:47:29 -0000	1.292
--- ia64.c	6 Jul 2004 00:30:58 -0000
*************** ia64_function_arg (CUMULATIVE_ARGS *cum,
*** 3752,3759 ****
  	}
  
        /* If we ended up using just one location, just return that one loc, but
! 	 change the mode back to the argument mode.  */
!       if (i == 1)
  	return gen_rtx_REG (mode, REGNO (XEXP (loc[0], 0)));
        else
  	return gen_rtx_PARALLEL (mode, gen_rtvec_v (i, loc));
--- 3752,3763 ----
  	}
  
        /* If we ended up using just one location, just return that one loc, but
! 	 change the mode back to the argument mode.  However, we can't do this
! 	 when hfa_mode is XFmode and mode is TImode.  In that case, we would
! 	 return a TImode reference to an FP reg, but FP regs can't hold TImode.
! 	 We need the PARALLEL to make this work.  This can happen for a union
! 	 containing a single __float80 member.  */
!       if (i == 1 && ! (hfa_mode == XFmode && mode == TImode))
  	return gen_rtx_REG (mode, REGNO (XEXP (loc[0], 0)));
        else
  	return gen_rtx_PARALLEL (mode, gen_rtvec_v (i, loc));


More information about the Gcc-patches mailing list