[patch] expr.c: Fix the failure of gcc.dg/compat/scalar-by-value-4.

Kazu Hirata kazu@cs.umass.edu
Sun Jun 29 13:56:00 GMT 2003


HI Jim,

> The patch is OK.  It looks a little overly complicated, but apparently
> we do have to handle cases 2 and 3 because there is some badly designed
> hardware out there, so we unfortunately need the extra complexity.

Thanks.  My patch had a typo.  I didn't have stack_pointer_rtx in one
of gen_rtx_PLUS.  Attached is the final patch that I committed.

Kazu Hirata

2003-06-29  Kazu Hirata  <kazu@cs.umass.edu>

	* expr.c (emit_single_push_insn): If padding is needed
	downward, adjust the stack pointer first, and then store the
	data into the stack location using an offset.

Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.556
diff -u -r1.556 expr.c
--- expr.c	27 Jun 2003 09:49:31 -0000	1.556
+++ expr.c	29 Jun 2003 13:31:21 -0000
@@ -3802,12 +3802,48 @@
     }
   if (GET_MODE_SIZE (mode) == rounded_size)
     dest_addr = gen_rtx_fmt_e (STACK_PUSH_CODE, Pmode, stack_pointer_rtx);
+  /* If we are to pad downward, adjust the stack pointer first and
+     then store X into the stack location using an offset.  This is
+     because emit_move_insn does not know how to pad; it does not have
+     access to type.  */
+  else if (FUNCTION_ARG_PADDING (mode, type) == downward)
+    {
+      unsigned padding_size = rounded_size - GET_MODE_SIZE (mode);
+      HOST_WIDE_INT offset;
+
+      emit_move_insn (stack_pointer_rtx,
+		      expand_binop (Pmode,
+#ifdef STACK_GROWS_DOWNWARD
+				    sub_optab,
+#else
+				    add_optab,
+#endif
+				    stack_pointer_rtx,
+				    GEN_INT (rounded_size),
+				    NULL_RTX, 0, OPTAB_LIB_WIDEN));
+
+      offset = (HOST_WIDE_INT) padding_size;
+#ifdef STACK_GROWS_DOWNWARD
+      if (STACK_PUSH_CODE == POST_DEC)
+	/* We have already decremented the stack pointer, so get the
+	   previous value.  */
+	offset += (HOST_WIDE_INT) rounded_size;
+#else
+      if (STACK_PUSH_CODE == POST_INC)
+	/* We have already incremented the stack pointer, so get the
+	   previous value.  */
+	offset -= (HOST_WIDE_INT) rounded_size;
+#endif
+      dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (offset));
+    }
   else
     {
 #ifdef STACK_GROWS_DOWNWARD
+      /* ??? This seems wrong if STACK_PUSH_CODE == POST_DEC.  */
       dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
 				GEN_INT (-(HOST_WIDE_INT) rounded_size));
 #else
+      /* ??? This seems wrong if STACK_PUSH_CODE == POST_INC.  */
       dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
 				GEN_INT (rounded_size));
 #endif



More information about the Gcc-patches mailing list