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: [PATCH] renesas abi and optimize mode switching


On Mon, 2003-10-06 at 16:09, Richard Henderson wrote:
> On Mon, Oct 06, 2003 at 03:24:49PM -0700, Eric Christopher wrote:
> > Lacking a better idea, yes.
> 
> You should document it then and also do
> 
> #if defined(MODE_ENTRY) != defined(MODE_EXIT)
> #error loser
> #endif
> 
> or something.

Attached :)

Bootstrapped x86-linux. tested on x86-linux, sh-elf, frv-elf, mips-elf.

OK?

-eric

-- 
Eric Christopher <echristo@redhat.com>

2003-10-10  Eric Christopher  <echristo@redhat.com>

        * lcm.c (optimize_mode_switching): Change NORMAL_MODE
        to MODE_ENTRY and MODE_EXIT. Add MODE_AFTER for insns
        that set mode.
        * config/sh/sh.h (MODE_ENTRY): New macro.
        (MODE_EXIT): Ditto.
        (MODE_AFTER): Ditto.
        * config/sh/sh.md: Change for MODE_AFTER. Add
        fp_set attribute.
        * doc/tm.texi: Document MODE_AFTER, MODE_ENTRY, and MODE_EXIT.

Index: lcm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/lcm.c,v
retrieving revision 1.56
diff -u -p -w -r1.56 lcm.c
--- lcm.c	19 Jul 2003 14:47:07 -0000	1.56
+++ lcm.c	10 Oct 2003 08:05:59 -0000
@@ -958,6 +958,12 @@ reg_becomes_live (rtx reg, rtx setter AT
       SET_HARD_REG_BIT (* (HARD_REG_SET *) live, regno + nregs);
 }
 
+/* Make sure if MODE_ENTRY is defined the MODE_EXIT is defined
+   and vice versa.  */
+#if defined (MODE_ENTRY) != defined (MODE_EXIT)
+ #error "Both MODE_ENTRY and MODE_EXIT must be defined"
+#endif
+
 /* Find all insns that need a particular mode setting, and insert the
    necessary mode switches.  Return true if we did work.  */
 
@@ -990,7 +996,7 @@ optimize_mode_switching (FILE *file)
 	/* Create the list of segments within each basic block.
 	   If NORMAL_MODE is defined, allow for two extra
 	   blocks split from the entry and exit block.  */
-#ifdef NORMAL_MODE
+#if defined (MODE_ENTRY) && defined (MODE_EXIT)
 	entry_exit_extra = 2;
 #endif
 	bb_info[n_entities]
@@ -1003,7 +1009,7 @@ optimize_mode_switching (FILE *file)
   if (! n_entities)
     return 0;
 
-#ifdef NORMAL_MODE
+#if defined (MODE_ENTRY) && defined (MODE_EXIT)
   {
     /* Split the edge from the entry block and the fallthrough edge to the
        exit block, so that we can note that there NORMAL_MODE is supplied /
@@ -1068,7 +1074,9 @@ optimize_mode_switching (FILE *file)
 		      add_seginfo (info + bb->index, ptr);
 		      RESET_BIT (transp[bb->index], j);
 		    }
-
+#ifdef MODE_AFTER
+		  last_mode = MODE_AFTER (last_mode, insn);
+#endif
 		  /* Update LIVE_NOW.  */
 		  for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
 		    if (REG_NOTE_KIND (link) == REG_DEAD)
@@ -1089,9 +1097,9 @@ optimize_mode_switching (FILE *file)
 	      add_seginfo (info + bb->index, ptr);
 	    }
 	}
-#ifdef NORMAL_MODE
+#if defined (MODE_ENTRY) && defined (MODE_EXIT)
       {
-	int mode = NORMAL_MODE (e);
+	int mode = MODE_ENTRY (e);
 
 	if (mode != no_mode)
 	  {
@@ -1109,7 +1117,7 @@ optimize_mode_switching (FILE *file)
 	    info[bb->index].computing = mode;
 
 	    if (pre_exit)
-	      info[pre_exit->index].seginfo->mode = mode;
+	      info[pre_exit->index].seginfo->mode = MODE_EXIT (e);
 	  }
       }
 #endif /* NORMAL_MODE */
@@ -1285,7 +1293,7 @@ optimize_mode_switching (FILE *file)
   if (need_commit)
     commit_edge_insertions ();
 
-#ifdef NORMAL_MODE
+#if defined (MODE_ENTRY) && defined (MODE_EXIT)
   cleanup_cfg (CLEANUP_NO_INSN_DEL);
 #else
   if (!need_commit && !emited)
Index: config/sh/sh.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.h,v
retrieving revision 1.223
diff -u -p -w -r1.223 sh.h
--- config/sh/sh.h	5 Oct 2003 19:50:56 -0000	1.223
+++ config/sh/sh.h	10 Oct 2003 08:06:01 -0000
@@ -3234,6 +3234,11 @@ extern int rtx_equal_function_value_matt
    ? (TARGET_FMOVD ? FP_MODE_DOUBLE : FP_MODE_NONE) \
    : ACTUAL_NORMAL_MODE (ENTITY))
 
+#define MODE_ENTRY(ENTITY) NORMAL_MODE (ENTITY)
+
+#define MODE_EXIT(ENTITY) \
+  (sh_cfun_attr_renesas_p () ? FP_MODE_NONE : NORMAL_MODE (ENTITY))
+
 #define EPILOGUE_USES(REGNO)       ((TARGET_SH2E || TARGET_SH4)		\
 				    && (REGNO) == FPSCR_REG)
 
@@ -3241,6 +3246,12 @@ extern int rtx_equal_function_value_matt
   (recog_memoized (INSN) >= 0						\
    ? get_attr_fp_mode (INSN)						\
    : FP_MODE_NONE)
+
+#define MODE_AFTER(MODE, INSN)                  \
+     (recog_memoized (INSN) >= 0                \
+      && get_attr_fp_set (INSN) != FP_SET_NONE  \
+      ? get_attr_fp_set (INSN)                  \
+      : (MODE))
 
 #define MODE_PRIORITY_TO_MODE(ENTITY, N) \
   ((TARGET_FPU_SINGLE != 0) ^ (N) ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
Index: config/sh/sh.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.md,v
retrieving revision 1.159
diff -u -p -w -r1.159 sh.md
--- config/sh/sh.md	27 Sep 2003 04:48:28 -0000	1.159
+++ config/sh/sh.md	10 Oct 2003 08:06:02 -0000
@@ -280,6 +280,14 @@
 
 (define_attr "fp_mode" "single,double,none" (const_string "none"))
 
+;; Indicate if the fpu mode is set by this instruction
+;; "unknown" must have the value as "none" in fp_mode, and means
+;; that the instruction/abi has left the processor in an unknown
+;; state.
+;; "none" means that nothing has changed and no mode is set.
+;; This attribute is only used for the Renesas ABI.
+(define_attr "fp_set" "single,double,unknown,none" (const_string "none"))
+
 ; If a conditional branch destination is within -252..258 bytes away
 ; from the instruction it can be 2 bytes long.  Something in the
 ; range -4090..4100 bytes can be 6 bytes long.  All other conditional
@@ -5562,7 +5570,8 @@
    (set (attr "fp_mode")
 	(if_then_else (eq_attr "fpu_single" "yes")
 		      (const_string "single") (const_string "double")))
-   (set_attr "needs_delay_slot" "yes")])
+   (set_attr "needs_delay_slot" "yes")
+   (set_attr "fp_set" "unknown")])
 
 ;; This is a pc-rel call, using bsrf, for use with PIC.
 
@@ -5579,7 +5588,8 @@
    (set (attr "fp_mode")
 	(if_then_else (eq_attr "fpu_single" "yes")
 		      (const_string "single") (const_string "double")))
-   (set_attr "needs_delay_slot" "yes")])
+   (set_attr "needs_delay_slot" "yes")
+   (set_attr "fp_set" "unknown")])
 
 (define_insn_and_split "call_pcrel"
   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
@@ -5607,7 +5617,8 @@
    (set (attr "fp_mode")
 	(if_then_else (eq_attr "fpu_single" "yes")
 		      (const_string "single") (const_string "double")))
-   (set_attr "needs_delay_slot" "yes")])
+   (set_attr "needs_delay_slot" "yes")
+   (set_attr "fp_set" "unknown")])
 
 (define_insn "call_compact"
   [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
@@ -5662,7 +5673,8 @@
    (set (attr "fp_mode")
 	(if_then_else (eq_attr "fpu_single" "yes")
 		      (const_string "single") (const_string "double")))
-   (set_attr "needs_delay_slot" "yes")])
+   (set_attr "needs_delay_slot" "yes")
+   (set_attr "fp_set" "unknown")])
 
 (define_insn "call_valuei_pcrel"
   [(set (match_operand 0 "" "=rf")
@@ -5678,7 +5690,8 @@
    (set (attr "fp_mode")
 	(if_then_else (eq_attr "fpu_single" "yes")
 		      (const_string "single") (const_string "double")))
-   (set_attr "needs_delay_slot" "yes")])
+   (set_attr "needs_delay_slot" "yes")
+   (set_attr "fp_set" "unknown")])
 
 (define_insn_and_split "call_value_pcrel"
   [(set (match_operand 0 "" "=rf")
@@ -5708,7 +5721,8 @@
    (set (attr "fp_mode")
 	(if_then_else (eq_attr "fpu_single" "yes")
 		      (const_string "single") (const_string "double")))
-   (set_attr "needs_delay_slot" "yes")])
+   (set_attr "needs_delay_slot" "yes")
+   (set_attr "fp_set" "unknown")])
 
 (define_insn "call_value_compact"
   [(set (match_operand 0 "" "=rf")
@@ -8169,7 +8183,8 @@ mov.l\\t1f,r0\\n\\
   [(set (reg:PSI FPSCR_REG)
 	(xor:PSI (reg:PSI FPSCR_REG) (const_int 1048576)))]
   "TARGET_SH4"
-  "fschg")
+  "fschg"
+  [(set_attr "fp_set" "unknown")])
 
 (define_expand "addsf3"
   [(set (match_operand:SF 0 "arith_reg_operand" "")



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