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]

[patch] xstormy16: Move predicates to predicates.md.


Hi,

Attached is a patch to move predicates to predicates.md.

Built xstormy16-elf.  OK to apply?

Kazu Hirata

2005-04-03  Kazu Hirata  <kazu@cs.umass.edu>

	* config/stormy16/stormy16-protos.h: Remove the prototypes for
	xstormy16_ineqsi_operator, equality_operator,
	inequality_operator, shift_operator,
	xstormy16_below100_operand, xstormy16_below100_or_register,
	xstormy16_splittable_below100_or_register,
	xstormy16_onebit_set_operand, xstormy16_onebit_clr_operand.
	* config/stormy16/stormy16.c (xstormy16_ineqsi_operator,
	equality_operator, inequality_operator,
	xstormy16_below100_operand, xstormy16_below100_or_register,
	xstormy16_splittable_below100_or_register,
	xstormy16_onebit_set_operand, xstormy16_onebit_clr_operand,
	nonimmediate_nonstack_operand, shift_operator): Move to
	predicates.md.
	* config/stormy16/stormy16.h (PREDICATE_CODES): Remove.
	* config/stormy16/stormy16.md: Include predicates.md.
	* config/stormy16/predicates.md: New.

Index: stormy16-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/stormy16/stormy16-protos.h,v
retrieving revision 1.18
diff -u -d -p -r1.18 stormy16-protos.h
--- stormy16-protos.h	17 Aug 2004 22:51:28 -0000	1.18
+++ stormy16-protos.h	3 Apr 2005 05:39:06 -0000
@@ -68,9 +68,6 @@ extern void xstormy16_expand_andqi3 (rtx
 #endif
 
 #if defined (HAVE_MACHINE_MODES) && defined (RTX_CODE)
-extern int xstormy16_ineqsi_operator (rtx, enum machine_mode);
-extern int equality_operator (rtx, enum machine_mode);
-extern int inequality_operator (rtx, enum machine_mode);
 extern void xstormy16_split_cbranch (enum machine_mode, rtx, rtx, rtx, rtx);
 extern int  short_memory_operand (rtx, enum machine_mode);
 extern int  nonimmediate_nonstack_operand (rtx, enum machine_mode);
@@ -85,15 +82,9 @@ extern void xstormy16_split_move (enum m
 extern void xstormy16_expand_move (enum machine_mode, rtx, rtx);
 extern void xstormy16_expand_arith (enum machine_mode, enum rtx_code, 
 				    rtx, rtx, rtx, rtx);
-extern int  shift_operator (rtx, enum machine_mode);
 extern const char * xstormy16_output_shift (enum machine_mode, enum rtx_code, 
 					    rtx, rtx, rtx);
 extern int  xstormy16_below100_symbol (rtx, enum machine_mode);
-extern int  xstormy16_below100_operand (rtx, enum machine_mode);
 extern int  xstormy16_splittable_below100_operand (rtx, enum machine_mode);
-extern int  xstormy16_below100_or_register (rtx, enum machine_mode);
-extern int  xstormy16_splittable_below100_or_register (rtx, enum machine_mode);
-extern int xstormy16_onebit_set_operand (rtx, enum machine_mode);
-extern int xstormy16_onebit_clr_operand (rtx, enum machine_mode);
 #endif
 
Index: stormy16.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/stormy16/stormy16.c,v
retrieving revision 1.72
diff -u -d -p -r1.72 stormy16.c
--- stormy16.c	1 Apr 2005 03:42:55 -0000	1.72
+++ stormy16.c	3 Apr 2005 05:39:06 -0000
@@ -65,34 +65,6 @@ static bool xstormy16_return_in_memory (
 struct rtx_def * xstormy16_compare_op0;
 struct rtx_def * xstormy16_compare_op1;
 
-/* Return 1 if this is a LT, GE, LTU, or GEU operator.  */
-
-int
-xstormy16_ineqsi_operator (register rtx op, enum machine_mode mode)
-{
-  enum rtx_code code = GET_CODE (op);
-  
-  return ((mode == VOIDmode || GET_MODE (op) == mode)
-	  && (code == LT || code == GE || code == LTU || code == GEU));
-}
-
-/* Return 1 if this is an EQ or NE operator.  */
-
-int
-equality_operator (register rtx op, enum machine_mode mode)
-{
-  return ((mode == VOIDmode || GET_MODE (op) == mode)
-	  && (GET_CODE (op) == EQ || GET_CODE (op) == NE));
-}
-
-/* Return 1 if this is a comparison operator but not an EQ or NE operator.  */
-
-int
-inequality_operator (register rtx op, enum machine_mode mode)
-{
-  return comparison_operator (op, mode) && ! equality_operator (op, mode);
-}
-
 /* Compute a (partial) cost for rtx X.  Return true if the complete
    cost has been computed, and false if subexpressions should be
    scanned.  In either case, *TOTAL contains the cost result.  */
@@ -576,28 +548,6 @@ xstormy16_below100_symbol (rtx x,
   return 0;
 }
 
-/* Predicate for MEMs that can use special 8-bit addressing.  */
-int
-xstormy16_below100_operand (rtx x, enum machine_mode mode)
-{
-  if (GET_MODE (x) != mode)
-    return 0;
-  if (GET_CODE (x) == MEM)
-    x = XEXP (x, 0);
-  else if (GET_CODE (x) == SUBREG
-	   && GET_CODE (XEXP (x, 0)) == MEM
-	   && !MEM_VOLATILE_P (XEXP (x, 0)))
-    x = XEXP (XEXP (x, 0), 0);
-  else
-    return 0;
-  if (GET_CODE (x) == CONST_INT)
-    {
-      HOST_WIDE_INT i = INTVAL (x);
-      return (i >= 0x7f00 && i < 0x7fff);
-    }
-  return xstormy16_below100_symbol (x, HImode);
-}
-
 /* Likewise, but only for non-volatile MEMs, for patterns where the
    MEM will get split into smaller sized accesses.  */
 int
@@ -608,52 +558,6 @@ xstormy16_splittable_below100_operand (r
   return xstormy16_below100_operand (x, mode);
 }
 
-int
-xstormy16_below100_or_register (rtx x, enum machine_mode mode)
-{
-  return (xstormy16_below100_operand (x, mode)
-	  || register_operand (x, mode));
-}
-
-int
-xstormy16_splittable_below100_or_register (rtx x, enum machine_mode mode)
-{
-  if (GET_CODE (x) == MEM && MEM_VOLATILE_P (x))
-    return 0;
-  return (xstormy16_below100_operand (x, mode)
-	  || register_operand (x, mode));
-}
-
-/* Predicate for constants with exactly one bit set.  */
-int
-xstormy16_onebit_set_operand (rtx x, enum machine_mode mode)
-{
-  HOST_WIDE_INT i;
-  if (GET_CODE (x) != CONST_INT)
-    return 0;
-  i = INTVAL (x);
-  if (mode == QImode)
-    i &= 0xff;
-  if (mode == HImode)
-    i &= 0xffff;
-  return exact_log2 (i) != -1;
-}
-
-/* Predicate for constants with exactly one bit not set.  */
-int
-xstormy16_onebit_clr_operand (rtx x, enum machine_mode mode)
-{
-  HOST_WIDE_INT i;
-  if (GET_CODE (x) != CONST_INT)
-    return 0;
-  i = ~ INTVAL (x);
-  if (mode == QImode)
-    i &= 0xff;
-  if (mode == HImode)
-    i &= 0xffff;
-  return exact_log2 (i) != -1;
-}
-
 /* Expand an 8-bit IOR.  This either detects the one case we can
    actually do, or uses a 16-bit IOR.  */
 void
@@ -875,15 +779,6 @@ short_memory_operand (rtx x, enum machin
   return (GET_CODE (XEXP (x, 0)) != PLUS);
 }
 
-int
-nonimmediate_nonstack_operand (rtx op, enum machine_mode mode)
-{
-  /* 'Q' is for pushes, 'R' for pops.  */
-  return (nonimmediate_operand (op, mode) 
-	  && ! xstormy16_extra_constraint_p (op, 'Q')
-	  && ! xstormy16_extra_constraint_p (op, 'R'));
-}
-
 /* Splitter for the 'move' patterns, for modes not directly implemented
    by hardware.  Emit insns to copy a value of mode MODE from SRC to
    DEST.
@@ -2238,18 +2133,6 @@ xstormy16_expand_arith (enum machine_mod
     emit (gen_nop ());
 }
 
-/* Return 1 if OP is a shift operator.  */
-
-int
-shift_operator (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
-{
-  enum rtx_code code = GET_CODE (op);
-
-  return (code == ASHIFT
-	  || code == ASHIFTRT
-	  || code == LSHIFTRT);
-}
-
 /* The shift operations are split at output time for constant values;
    variable-width shifts get handed off to a library routine.  
 
Index: stormy16.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/stormy16/stormy16.h,v
retrieving revision 1.95
diff -u -d -p -r1.95 stormy16.h
--- stormy16.h	3 Apr 2005 05:37:21 -0000	1.95
+++ stormy16.h	3 Apr 2005 05:39:06 -0000
@@ -810,18 +810,6 @@ do  {						\
 
 /* Miscellaneous Parameters.  */
 
-#define PREDICATE_CODES					\
-  {"shift_operator", {ASHIFT, ASHIFTRT, LSHIFTRT }},	\
-  {"equality_operator", {EQ, NE }},			\
-  {"inequality_operator", {GE, GT, LE, LT, GEU, GTU, LEU, LTU }}, \
-  {"xstormy16_ineqsi_operator", {LT, GE, LTU, GEU }}, \
-  {"xstormy16_below100_operand", {MEM }}, \
-  {"xstormy16_below100_or_register", {MEM, REG, SUBREG }}, \
-  {"xstormy16_splittable_below100_or_register", {MEM, REG, SUBREG }}, \
-  {"xstormy16_onebit_clr_operand", {CONST_INT }}, \
-  {"xstormy16_onebit_set_operand", {CONST_INT }}, \
-  {"nonimmediate_nonstack_operand", {REG, MEM, SUBREG }},
-
 #define CASE_VECTOR_MODE SImode
 
 #define WORD_REGISTER_OPERATIONS
Index: stormy16.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/stormy16/stormy16.md,v
retrieving revision 1.19
diff -u -d -p -r1.19 stormy16.md
--- stormy16.md	1 Apr 2005 03:42:55 -0000	1.19
+++ stormy16.md	3 Apr 2005 05:39:07 -0000
@@ -1,5 +1,5 @@
 ;; XSTORMY16 Machine description template
-;; Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003, 2004
+;; Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005
 ;; Free Software Foundation, Inc.
 ;; Contributed by Red Hat, Inc.
 
@@ -91,6 +91,7 @@
 (define_asm_attributes [(set_attr "length" "4")
 			(set_attr "psw_operand" "clobber")])
 
+(include "predicates.md")
 
 ;; ::::::::::::::::::::
 ;; ::
--- /dev/null	2005-03-29 05:55:50.256877624 -0500
+++ predicates.md	2005-04-03 00:37:36.077853536 -0500
@@ -0,0 +1,146 @@
+;; Predicate definitions for XSTORMY16.
+;; Copyright (C) 2005 Free Software Foundation, Inc.
+;;
+;; This file is part of GCC.
+;;
+;; GCC is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;;
+;; GCC is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GCC; see the file COPYING.  If not, write to
+;; the Free Software Foundation, 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; Return 1 if OP is a shift operator.
+
+(define_predicate "shift_operator"
+  (match_code "ashift,ashiftrt,lshiftrt")
+{
+  enum rtx_code code = GET_CODE (op);
+
+  return (code == ASHIFT
+	  || code == ASHIFTRT
+	  || code == LSHIFTRT);
+})
+
+;; Return 1 if this is an EQ or NE operator.
+
+(define_predicate "equality_operator"
+  (match_code "eq,ne")
+{
+  return ((mode == VOIDmode || GET_MODE (op) == mode)
+	  && (GET_CODE (op) == EQ || GET_CODE (op) == NE));
+})
+
+;; Return 1 if this is a comparison operator but not an EQ or NE
+;; operator.
+
+(define_predicate "inequality_operator"
+  (match_code "ge,gt,le,lt,geu,gtu,leu,ltu")
+{
+  return comparison_operator (op, mode) && ! equality_operator (op, mode);
+})
+
+;; Return 1 if this is a LT, GE, LTU, or GEU operator.
+
+(define_predicate "xstormy16_ineqsi_operator"
+  (match_code "lt,ge,ltu,geu")
+{
+  enum rtx_code code = GET_CODE (op);
+  
+  return ((mode == VOIDmode || GET_MODE (op) == mode)
+	  && (code == LT || code == GE || code == LTU || code == GEU));
+})
+
+;; Predicate for MEMs that can use special 8-bit addressing.
+
+(define_predicate "xstormy16_below100_operand"
+  (match_code "mem")
+{
+  if (GET_MODE (op) != mode)
+    return 0;
+  if (GET_CODE (op) == MEM)
+    op = XEXP (op, 0);
+  else if (GET_CODE (op) == SUBREG
+	   && GET_CODE (XEXP (op, 0)) == MEM
+	   && !MEM_VOLATILE_P (XEXP (op, 0)))
+    op = XEXP (XEXP (op, 0), 0);
+  else
+    return 0;
+  if (GET_CODE (op) == CONST_INT)
+    {
+      HOST_WIDE_INT i = INTVAL (op);
+      return (i >= 0x7f00 && i < 0x7fff);
+    }
+  return xstormy16_below100_symbol (op, HImode);
+})
+
+;; TODO: Add a comment here.
+
+(define_predicate "xstormy16_below100_or_register"
+  (match_code "mem,reg,subreg")
+{
+  return (xstormy16_below100_operand (op, mode)
+	  || register_operand (op, mode));
+})
+
+;; TODO: Add a comment here.
+
+(define_predicate "xstormy16_splittable_below100_or_register"
+  (match_code "mem,reg,subreg")
+{
+  if (GET_CODE (op) == MEM && MEM_VOLATILE_P (op))
+    return 0;
+  return (xstormy16_below100_operand (op, mode)
+	  || register_operand (op, mode));
+})
+
+;; Predicate for constants with exactly one bit not set.
+
+(define_predicate "xstormy16_onebit_clr_operand"
+  (match_code "const_int")
+{
+  HOST_WIDE_INT i;
+  if (GET_CODE (op) != CONST_INT)
+    return 0;
+  i = ~ INTVAL (op);
+  if (mode == QImode)
+    i &= 0xff;
+  if (mode == HImode)
+    i &= 0xffff;
+  return exact_log2 (i) != -1;
+})
+
+;; Predicate for constants with exactly one bit set.
+
+(define_predicate "xstormy16_onebit_set_operand"
+  (match_code "const_int")
+{
+  HOST_WIDE_INT i;
+  if (GET_CODE (op) != CONST_INT)
+    return 0;
+  i = INTVAL (op);
+  if (mode == QImode)
+    i &= 0xff;
+  if (mode == HImode)
+    i &= 0xffff;
+  return exact_log2 (i) != -1;
+})
+
+;; TODO: Add a comment here.
+
+(define_predicate "nonimmediate_nonstack_operand"
+  (match_code "reg,mem,subreg")
+{
+  /* 'Q' is for pushes, 'R' for pops.  */
+  return (nonimmediate_operand (op, mode) 
+	  && ! xstormy16_extra_constraint_p (op, 'Q')
+	  && ! xstormy16_extra_constraint_p (op, 'R'));
+})


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