diff gcc/config/h8300/h8300.c @ 63:b7f97abdc517 gcc-4.6-20100522

update gcc from gcc-4.5.0 to gcc-4.6
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 24 May 2010 12:47:05 +0900
parents 77e2b8dfacca
children f6334be47118
line wrap: on
line diff
--- a/gcc/config/h8300/h8300.c	Fri Feb 12 23:41:23 2010 +0900
+++ b/gcc/config/h8300/h8300.c	Mon May 24 12:47:05 2010 +0900
@@ -1,6 +1,6 @@
 /* Subroutines for insn-output.c for Renesas H8/300.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Steve Chamberlain (sac@cygnus.com),
    Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com).
@@ -29,7 +29,6 @@
 #include "tree.h"
 #include "regs.h"
 #include "hard-reg-set.h"
-#include "real.h"
 #include "insn-config.h"
 #include "conditions.h"
 #include "output.h"
@@ -83,7 +82,7 @@
 static int h8300_saveall_function_p (tree);
 static int h8300_monitor_function_p (tree);
 static int h8300_os_task_function_p (tree);
-static void h8300_emit_stack_adjustment (int, HOST_WIDE_INT);
+static void h8300_emit_stack_adjustment (int, HOST_WIDE_INT, bool);
 static HOST_WIDE_INT round_frame_size (HOST_WIDE_INT);
 static unsigned int compute_saved_regs (void);
 static void push (int);
@@ -98,7 +97,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);
@@ -509,9 +508,10 @@
 
 /* We use this to wrap all emitted insns in the prologue.  */
 static rtx
-F (rtx x)
+F (rtx x, bool set_it)
 {
-  RTX_FRAME_RELATED_P (x) = 1;
+  if (set_it)
+    RTX_FRAME_RELATED_P (x) = 1;
   return x;
 }
 
@@ -528,7 +528,7 @@
   int i;
 
   for (i = 0; i < len; i++)
-    F (XVECEXP (par, 0, i));
+    F (XVECEXP (par, 0, i), true);
 
   return par;
 }
@@ -537,7 +537,7 @@
    SIZE to adjust the stack pointer.  */
 
 static void
-h8300_emit_stack_adjustment (int sign, HOST_WIDE_INT size)
+h8300_emit_stack_adjustment (int sign, HOST_WIDE_INT size, bool in_prologue)
 {
   /* If the frame size is 0, we don't have anything to do.  */
   if (size == 0)
@@ -552,9 +552,9 @@
       && !(cfun->static_chain_decl != NULL && sign < 0))
     {
       rtx r3 = gen_rtx_REG (Pmode, 3);
-      F (emit_insn (gen_movhi (r3, GEN_INT (sign * size))));
+      F (emit_insn (gen_movhi (r3, GEN_INT (sign * size))), in_prologue);
       F (emit_insn (gen_addhi3 (stack_pointer_rtx,
-				stack_pointer_rtx, r3)));
+				stack_pointer_rtx, r3)), in_prologue);
     }
   else
     {
@@ -568,11 +568,11 @@
 	  rtx x = emit_insn (gen_addhi3 (stack_pointer_rtx,
 					 stack_pointer_rtx, GEN_INT (sign * size)));
 	  if (size < 4)
-	    F (x);
+	    F (x, in_prologue);
 	}
       else
 	F (emit_insn (gen_addsi3 (stack_pointer_rtx,
-				  stack_pointer_rtx, GEN_INT (sign * size))));
+				  stack_pointer_rtx, GEN_INT (sign * size))), in_prologue);
     }
 }
 
@@ -622,7 +622,7 @@
     x = gen_push_h8300hs_advanced (reg);
   else
     x = gen_push_h8300hs_normal (reg);
-  x = F (emit_insn (x));
+  x = F (emit_insn (x), true);
   REG_NOTES (x) = gen_rtx_EXPR_LIST (REG_INC, stack_pointer_rtx, 0);
 }
 
@@ -661,7 +661,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;
@@ -679,7 +679,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;
 
@@ -719,7 +719,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.  */
@@ -854,7 +858,7 @@
     {
       /* Push fp.  */
       push (HARD_FRAME_POINTER_REGNUM);
-      F (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx));
+      F (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx), true);
     }
 
   /* Push the rest of the registers in ascending order.  */
@@ -880,12 +884,12 @@
 		n_regs = 2;
 	    }
 
-	  h8300_push_pop (regno, n_regs, 0, 0);
+	  h8300_push_pop (regno, n_regs, false, false);
 	}
     }
 
   /* Leave room for locals.  */
-  h8300_emit_stack_adjustment (-1, round_frame_size (get_frame_size ()));
+  h8300_emit_stack_adjustment (-1, round_frame_size (get_frame_size ()), true);
 }
 
 /* Return nonzero if we can use "rts" for the function currently being
@@ -920,7 +924,7 @@
   returned_p = false;
 
   /* Deallocate locals.  */
-  h8300_emit_stack_adjustment (1, frame_size);
+  h8300_emit_stack_adjustment (1, frame_size, false);
 
   /* Pop the saved registers in descending order.  */
   saved_regs = compute_saved_regs ();
@@ -953,7 +957,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);
 	}
     }
 
@@ -962,7 +966,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)
@@ -1463,12 +1467,20 @@
 	goto def;
       break;
     case 'V':
-      bitint = exact_log2 (INTVAL (x) & 0xff);
+      bitint = (INTVAL (x) & 0xffff);
+      if ((exact_log2 ((bitint >> 8) & 0xff)) == -1)
+	bitint = exact_log2 (bitint & 0xff);
+      else
+        bitint = exact_log2 ((bitint >> 8) & 0xff);	      
       gcc_assert (bitint >= 0);
       fprintf (file, "#%d", bitint);
       break;
     case 'W':
-      bitint = exact_log2 ((~INTVAL (x)) & 0xff);
+      bitint = ((~INTVAL (x)) & 0xffff);
+      if ((exact_log2 ((bitint >> 8) & 0xff)) == -1 )
+	bitint = exact_log2 (bitint & 0xff);
+      else
+	bitint = (exact_log2 ((bitint >> 8) & 0xff));      
       gcc_assert (bitint >= 0);
       fprintf (file, "#%d", bitint);
       break;