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: [PING^2]fr30 movdi patch


> Hi Lars,
>
> > Again,
> > http://gcc.gnu.org/ml/gcc-patches/2007-02/msg01272.html
>
> Umm - there does not appear to be either a test case or a patch attached
> to this email....

Sorry, I must have missed that, here comes the patch.

Do you still need a test case ? It would be difficult to supply one, because 
the problem only occurs in big functions, where the compiler is not able to 
use enough registers for di transfer.
I discovered it as part of the ecos operating system, file 
packages/infra/current/src/diag.cxx function _vprintf.

Lars
Index: gcc/config/fr30/fr30.md
===================================================================
--- gcc/config/fr30/fr30.md	(Revision 121880)
+++ gcc/config/fr30/fr30.md	(Arbeitskopie)
@@ -379,22 +380,24 @@
 ;; (This code is stolen from the M32R port.)
 
 (define_expand "movdi"
-  [(set (match_operand:DI 0 "general_operand" "")
-	(match_operand:DI 1 "general_operand" ""))]
+  [(set (match_operand:DI 0 "nonimmediate_operand" "")
+  (match_operand:DI 1 "general_operand" ""))]
   ""
   "
   /* Everything except mem = const or mem = mem can be done easily.  */
-  
-  if (GET_CODE (operands[0]) == MEM)
-    operands[1] = force_reg (DImode, operands[1]);
+
+  if (GET_CODE (operands[0]) == MEM){
+     operands[1] = force_reg (DImode, operands[1]);
+  }
   ")
 
+
 ;; We use an insn and a split so that we can generate
 ;; RTL rather than text from fr30_move_double().
 
 (define_insn "*movdi_insn"
   [(set (match_operand:DI 0 "nonimmediate_di_operand" "=r,r,m,r")
-	(match_operand:DI 1 "di_operand"               "r,m,r,nF"))]
+        (match_operand:DI 1 "di_operand"               "r,m,r,nF"))]
   "register_operand (operands[0], DImode) || register_operand (operands[1], DImode)"
   "#"
   [(set_attr "length" "4,8,12,12")]
@@ -402,7 +405,7 @@
 
 (define_split
   [(set (match_operand:DI 0 "nonimmediate_di_operand" "")
-	(match_operand:DI 1 "di_operand" ""))]
+        (match_operand:DI 1 "di_operand" ""))]
   "reload_completed"
   [(match_dup 2)]
   "operands[2] = fr30_move_double (operands);")
Index: gcc/config/fr30/fr30.c
===================================================================
--- gcc/config/fr30/fr30.c	(Revision 121880)
+++ gcc/config/fr30/fr30.c	(Arbeitskopie)
@@ -885,50 +885,50 @@ fr30_move_double (rtx * operands)
     }
   else if (src_code == REG && dest_code == MEM)
     {
+
       rtx addr = XEXP (dest, 0);
       rtx src0;
       rtx src1;
 
       gcc_assert (GET_CODE (addr) == REG);
-      
+
       src0 = operand_subword (src, 0, TRUE, mode);
       src1 = operand_subword (src, 1, TRUE, mode);
-      
-      emit_insn (gen_rtx_SET (VOIDmode, adjust_address (dest, SImode, 0),
-			      src0));
+
+
+      emit_move_insn (adjust_address (dest, SImode, 0), src0);
 
       if (REGNO (addr) == STACK_POINTER_REGNUM
 	  || REGNO (addr) == FRAME_POINTER_REGNUM)
-	emit_insn (gen_rtx_SET (VOIDmode,
+      emit_insn (gen_rtx_SET (VOIDmode,
 				adjust_address (dest, SImode, UNITS_PER_WORD),
 				src1));
       else
 	{
 	  rtx new_mem;
-	  
+      rtx scratch_reg_r0 = gen_rtx_REG(SImode, 0);
 	  /* We need a scratch register to hold the value of 'address + 4'.
-	     We ought to allow gcc to find one for us, but for now, just
-	     push one of the source registers.  */
-	  emit_insn (gen_movsi_push (src0));
-	  emit_insn (gen_movsi_internal (src0, addr));
-	  emit_insn (gen_addsi_small_int (src0, src0, GEN_INT (UNITS_PER_WORD)));
-	  
-	  new_mem = gen_rtx_MEM (SImode, src0);
-	  MEM_COPY_ATTRIBUTES (new_mem, dest);
-	  
-	  emit_insn (gen_rtx_SET (VOIDmode, new_mem, src1));
-	  emit_insn (gen_movsi_pop (src0));
+	     We use r0 for this purpose. It is used for example for long
+	     jumps and is already marked to not be used by normal register
+	     allocation. */
+      emit_insn (gen_movsi_internal (scratch_reg_r0, addr));
+      emit_insn (gen_addsi_small_int (scratch_reg_r0, scratch_reg_r0, GEN_INT (UNITS_PER_WORD)));
+      new_mem = gen_rtx_MEM (SImode, scratch_reg_r0);
+      MEM_COPY_ATTRIBUTES (new_mem, dest);
+      emit_move_insn (new_mem, src1);
+      emit_insn (gen_blockage ());
 	}
     }
   else
-    /* This should have been prevented by the constraints on movdi_insn.  */
-    gcc_unreachable ();
-  
+  /* This should have been prevented by the constraints on movdi_insn.  */
+  gcc_unreachable ();
+
   val = get_insns ();
   end_sequence ();
 
   return val;
 }
+
 /*}}}*/
 /* Local Variables: */
 /* folded-file: t   */

Attachment: pgp00000.pgp
Description: PGP signature


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