H8300: RFA: Use emit_jump_insn for pops that return

Nick Clifton nickc@redhat.com
Mon Feb 15 13:34:00 GMT 2010


Hi Jeff, Hi Kazu,

  I recently ran into a problem with the H8300 port where it was
  emitting a parallel insn containing a (return) using emit_insn rather
  than emit_jump_insn.  I traced this down to the h8300_push_pop()
  function which was always using emit_insn() even when return_p was
  true.

  In the course of fixing this I also noticed several places where
  integer parameters were being used when boolean ones would be more
  appropriate, so the patch below also corrects this.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2010-02-15  Nick Clifton  <nickc@redhat.com>

	* config/h8300/h8300.c: (h8300_push_pop): Use bool type for
	boolean parameters.  Use emit_jump_insn when emitting a pop
	instruction containing a return insn.
        (push): Use 'true' rather than '1' as second parameter to F.
        (h8300_expand_prologue): Likewise.
        Use 'true' and 'false' for boolean parameters to
	h8300_push_pop.
        (h8300_expand_epilogue): Likewise.

Index: gcc/config/h8300/h8300.c
===================================================================
--- gcc/config/h8300/h8300.c	(revision 156733)
+++ gcc/config/h8300/h8300.c	(working copy)
@@ -98,7 +98,7 @@
 #endif
 static int h8300_and_costs (rtx);
 static int h8300_shift_costs (rtx);
-static void          h8300_push_pop               (int, int, int, int);
+static void          h8300_push_pop               (int, int, bool, bool);
 static int           h8300_stack_offset_p         (rtx, int);
 static int           h8300_ldm_stm_regno          (rtx, int, int, int);
 static void          h8300_reorg                  (void);
@@ -623,7 +623,7 @@
     x = gen_push_h8300hs_advanced (reg);
   else
     x = gen_push_h8300hs_normal (reg);
-  x = F (emit_insn (x), 1);
+  x = F (emit_insn (x), true);
   REG_NOTES (x) = gen_rtx_EXPR_LIST (REG_INC, stack_pointer_rtx, 0);
 }
 
@@ -662,7 +662,7 @@
 	(set sp (plus sp (const_int adjust)))]  */
 
 static void
-h8300_push_pop (int regno, int nregs, int pop_p, int return_p)
+h8300_push_pop (int regno, int nregs, bool pop_p, bool return_p)
 {
   int i, j;
   rtvec vec;
@@ -680,7 +680,7 @@
 
   /* We need one element for the return insn, if present, one for each
      register, and one for stack adjustment.  */
-  vec = rtvec_alloc ((return_p != 0) + nregs + 1);
+  vec = rtvec_alloc ((return_p ? 1 : 0) + nregs + 1);
   sp = stack_pointer_rtx;
   i = 0;
 
@@ -720,7 +720,11 @@
   x = gen_rtx_PARALLEL (VOIDmode, vec);
   if (!pop_p)
     x = Fpa (x);
-  emit_insn (x);
+
+  if (return_p)
+    emit_jump_insn (x);
+  else
+    emit_insn (x);
 }
 
 /* Return true if X has the value sp + OFFSET.  */
@@ -855,7 +859,7 @@
     {
       /* Push fp.  */
       push (HARD_FRAME_POINTER_REGNUM);
-      F (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx), 1);
+      F (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx), true);
     }
 
   /* Push the rest of the registers in ascending order.  */
@@ -881,7 +885,7 @@
 		n_regs = 2;
 	    }
 
-	  h8300_push_pop (regno, n_regs, 0, 0);
+	  h8300_push_pop (regno, n_regs, false, false);
 	}
     }
 
@@ -954,7 +958,7 @@
 	      && (saved_regs & ((1 << (regno - n_regs + 1)) - 1)) == 0)
 	    returned_p = true;
 
-	  h8300_push_pop (regno - n_regs + 1, n_regs, 1, returned_p);
+	  h8300_push_pop (regno - n_regs + 1, n_regs, true, returned_p);
 	}
     }
 
@@ -963,7 +967,7 @@
     {
       if (TARGET_H8300SX)
 	returned_p = true;
-      h8300_push_pop (HARD_FRAME_POINTER_REGNUM, 1, 1, returned_p);
+      h8300_push_pop (HARD_FRAME_POINTER_REGNUM, 1, true, returned_p);
     }
 
   if (!returned_p)



More information about the Gcc-patches mailing list