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]

[mep] enforce alignment in builtin_saveregs


Committed.

	* config/mep/mep.c (mep_expand_builtin_saveregs): Make sure 64-bit
	types are dword-aligned.
	(mep_expand_va_start): Likewise.
 
Index: config/mep/mep.c
===================================================================
--- config/mep/mep.c	(revision 150135)
+++ config/mep/mep.c	(working copy)
@@ -3527,21 +3527,29 @@ static rtx
 mep_expand_builtin_saveregs (void)
 {
   int bufsize, i, ns;
   rtx regbuf;
 
   ns = cfun->machine->arg_regs_to_save;
-  bufsize = ns * (TARGET_IVC2 ? 12 : 4);
-  regbuf = assign_stack_local (SImode, bufsize, 32);
+  if (TARGET_IVC2)
+    {
+      bufsize = 8 * ((ns + 1) / 2) + 8 * ns;
+      regbuf = assign_stack_local (SImode, bufsize, 64);
+    }
+  else
+    {
+      bufsize = ns * 4;
+      regbuf = assign_stack_local (SImode, bufsize, 32);
+    }
 
   move_block_from_reg (5-ns, regbuf, ns);
 
   if (TARGET_IVC2)
     {
       rtx tmp = gen_rtx_MEM (DImode, XEXP (regbuf, 0));
-      int ofs = 4 * ns;
+      int ofs = 8 * ((ns+1)/2);
 
       for (i=0; i<ns; i++)
 	{
 	  int rn = (4-ns) + i + 49;
 	  rtx ptr;
 
@@ -3624,13 +3632,15 @@ mep_expand_va_start (tree valist, rtx ne
   u = fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, u,
 		   size_int (4 * ns));
   t = build2 (MODIFY_EXPR, ptr_type_node, next_gp_limit, u);
   TREE_SIDE_EFFECTS (t) = 1;
   expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
 
-  /* va_list.next_cop = va_list.next_gp_limit; */
+  u = fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, u,
+		   size_int (8 * ((ns+1)/2)));
+  /* va_list.next_cop = ROUND_UP(va_list.next_gp_limit,8); */
   t = build2 (MODIFY_EXPR, ptr_type_node, next_cop, u);
   TREE_SIDE_EFFECTS (t) = 1;
   expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
 
   /* va_list.next_stack = nextarg; */
   u = make_tree (ptr_type_node, nextarg);


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