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]

SH md fpu_switch[01] simplifications


This patch allows us to use the fpu_switch[01] expanders in
fpscr_set_from_mem().  Ok to install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* config/sh/sh.md (fpu_switch0, fpu_switch1): Simplify.
	* config/sh/sh.c (fpscr_set_from_mem): Use them.

Index: gcc/config/sh/sh.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh.md,v
retrieving revision 1.38
diff -u -p -r1.38 sh.md
--- gcc/config/sh/sh.md	2000/08/07 09:58:29	1.38
+++ gcc/config/sh/sh.md	2000/08/17 11:58:50
@@ -3884,27 +3884,25 @@
 ;; ??? All patterns should have a type attribute.
 
 (define_expand "fpu_switch0"
-  [(set (match_operand:SI 0 "" "") (symbol_ref "__fpscr_values"))
-   (set (match_dup 2) (match_dup 1))]
+  [(set (match_operand:SI 0 "" "") (match_dup 2))
+   (set (match_dup 1) (mem:PSI (match_dup 0)))]
   ""
   "
 {
-  operands[1] = gen_rtx (MEM, PSImode, operands[0]);
-  RTX_UNCHANGING_P (operands[1]) = 1;
-  operands[2] = get_fpscr_rtx ();
+  operands[1] = get_fpscr_rtx ();
+  operands[2] = gen_rtx_SYMBOL_REF (SImode, \"__fpscr_values\");
 }")
 
 (define_expand "fpu_switch1"
-  [(set (match_operand:SI 0 "" "") (symbol_ref "__fpscr_values"))
-   (set (match_dup 1) (plus:SI (match_dup 0) (const_int 4)))
-   (set (match_dup 3) (match_dup 2))]
+  [(set (match_operand:SI 0 "" "") (match_dup 2))
+   (set (match_dup 3) (plus:SI (match_dup 0) (const_int 4)))
+   (set (match_dup 1) (mem:PSI (match_dup 3)))]
   ""
   "
 {
-  operands[1] = gen_reg_rtx (SImode);
-  operands[2] = gen_rtx (MEM, PSImode, operands[1]);
-  RTX_UNCHANGING_P (operands[2]) = 1;
-  operands[3] = get_fpscr_rtx ();
+  operands[1] = get_fpscr_rtx ();
+  operands[2] = gen_rtx_SYMBOL_REF (SImode, \"__fpscr_values\");
+  operands[3] = no_new_pseudos ? operands[0] : gen_reg_rtx (SImode);
 }")
 
 (define_expand "movpsi"
Index: gcc/config/sh/sh.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh.c,v
retrieving revision 1.57
diff -u -p -r1.57 sh.c
--- gcc/config/sh/sh.c	2000/08/07 09:58:29	1.57
+++ gcc/config/sh/sh.c	2000/08/17 11:58:55
@@ -5106,28 +5106,10 @@ fpscr_set_from_mem (mode, regs_live)
      HARD_REG_SET regs_live;
 {
   enum attr_fp_mode fp_mode = mode;
-  rtx i;
-  rtx sym;
   rtx addr_reg = get_free_reg (regs_live);
 
-  sym = gen_rtx_SYMBOL_REF (SImode, "__fpscr_values");
-  i = gen_rtx_SET (VOIDmode, addr_reg, sym);
-  emit_insn (i);
-  if (fp_mode == (TARGET_FPU_SINGLE ? FP_MODE_SINGLE : FP_MODE_DOUBLE))
-    {
-      rtx r = addr_reg;
-      addr_reg = get_free_reg (regs_live);
-      i = gen_rtx_SET (VOIDmode, addr_reg,
-		       gen_rtx_PLUS (Pmode, r, GEN_INT (4)));
-      emit_insn (i);
-    }
-  
-  i = gen_rtx_SET (VOIDmode, 
- 		   get_fpscr_rtx (), 
-  		   gen_rtx_MEM (PSImode, gen_rtx_POST_INC (Pmode, addr_reg)));
-  i = emit_insn (i);
-  REG_NOTES (i) = gen_rtx_EXPR_LIST (REG_DEAD, addr_reg, REG_NOTES (i));
-  REG_NOTES (i) = gen_rtx_EXPR_LIST (REG_INC, addr_reg, REG_NOTES (i));
+  emit_insn ((fp_mode == (TARGET_FPU_SINGLE ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
+	      ? gen_fpu_switch1 : gen_fpu_switch0) (addr_reg));
 }
 
 /* Is the given character a logical line separator for the assembler?  */

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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