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]

RFA: Fix compat/struct-by-value tests for big endian targets (Was: function parms in regs, patch 2 of 3)


+		  else if (size != UNITS_PER_WORD
+			   && BYTES_BIG_ENDIAN)
+		    {
+		      rtx tem, x;
+		      int by = (UNITS_PER_WORD - size) * BITS_PER_UNIT;
+		      rtx reg = gen_rtx_REG (word_mode, REGNO (entry_parm));
+
+		      x = expand_binop (word_mode, ashl_optab, reg,
+					GEN_INT (by), 0, 1, OPTAB_WIDEN);
+		      tem = change_address (mem, word_mode, 0);
+		      emit_move_insn (tem, x);
+		    }

This causes failures for big endian sh-elf in the
gcc.dg/compat/struct-by-value-[1-4] tests.

When compiling code like:

struct S0
{
  unsigned char i[0];
};

extern void check0 (struct S0 x, int i);

void
test0 (struct S0 s1, struct S0 s2, struct S0 s3)
{
  check0 (s1, 64);
  check0 (s2, 128);
  check0 (s3, 192);
}

the incoming arguments are shifted by the word size, and
then stored with 0 offset on the stack, clobbering the
return address.  The little endian version of the code in
assign_parms doesn't really do anything, which is what we
want.

-- 
--------------------------
SuperH (UK) Ltd.
2410 Aztec West / Almondsbury / BRISTOL / BS32 4QX
T:+44 1454 465658
2003-05-15  J"orn Rennecke <joern.rennecke@superh.com>

	* function.c (assign_parms): Don't shift by word size nor
	clobber the stack for 0 sized arguments.

Index: function.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/function.c,v
retrieving revision 1.427
diff -p -r1.427 function.c
*** function.c	11 May 2003 19:21:31 -0000	1.427
--- function.c	15 May 2003 16:43:30 -0000
*************** assign_parms (fndecl)
*** 4818,4823 ****
--- 4818,4824 ----
  		     to memory.  Note that the previous test doesn't
  		     handle all cases (e.g. SIZE == 3).  */
  		  else if (size != UNITS_PER_WORD
+ 			   && size != 0
  			   && BYTES_BIG_ENDIAN)
  		    {
  		      rtx tem, x;

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