Patchwork [01/14] rx: Move SELECT_CC_MODE to function.

login
register
mail settings
Submitter Richard Henderson
Date Jan. 14, 2011, 4:08 p.m.
Message ID <1295021309-28608-2-git-send-email-rth@redhat.com>
Download mbox | patch
Permalink /patch/78934/
State New
Headers show

Comments

Richard Henderson - Jan. 14, 2011, 4:08 p.m.
From: Richard Henderson <rth@twiddle.net>

---
 gcc/config/rx/rx-modes.def |    2 ++
 gcc/config/rx/rx-protos.h  |    2 ++
 gcc/config/rx/rx.c         |   29 +++++++++++++++++++++++++++++
 gcc/config/rx/rx.h         |   10 +---------
 4 files changed, 34 insertions(+), 9 deletions(-)

Patch

diff --git a/gcc/config/rx/rx-modes.def b/gcc/config/rx/rx-modes.def
index 0c4c192..31e3225 100644
--- a/gcc/config/rx/rx-modes.def
+++ b/gcc/config/rx/rx-modes.def
@@ -21,3 +21,5 @@ 
 CC_MODE (CC_ZS);
 CC_MODE (CC_ZSO);
 CC_MODE (CC_ZSC);
+
+CC_MODE (CC_F);		/* fcmp */
diff --git a/gcc/config/rx/rx-protos.h b/gcc/config/rx/rx-protos.h
index 528ccb3..c5b7b6c 100644
--- a/gcc/config/rx/rx-protos.h
+++ b/gcc/config/rx/rx-protos.h
@@ -24,6 +24,7 @@ 
 /* A few abbreviations to make the prototypes shorter.  */
 #define Mmode 	enum machine_mode
 #define Fargs	CUMULATIVE_ARGS
+#define Rcode	enum rtx_code
 
 extern void		rx_expand_prologue (void);
 extern int		rx_initial_elimination_offset (int, int);
@@ -40,6 +41,7 @@  extern bool		rx_is_legitimate_constant (rtx);
 extern bool 		rx_is_mode_dependent_addr (rtx);
 extern bool		rx_is_restricted_memory_address (rtx, Mmode);
 extern void		rx_notice_update_cc (rtx body, rtx insn);
+extern Mmode		rx_select_cc_mode (Rcode, rtx, rtx);
 #endif
 
 #endif /* GCC_RX_PROTOS_H */
diff --git a/gcc/config/rx/rx.c b/gcc/config/rx/rx.c
index 8f6f384..b5a996f 100644
--- a/gcc/config/rx/rx.c
+++ b/gcc/config/rx/rx.c
@@ -2756,6 +2756,35 @@  rx_memory_move_cost (enum machine_mode mode, reg_class_t regclass, bool in)
 {
   return 2 + memory_move_secondary_cost (mode, regclass, in);
 }
+
+/* Return the minimal CC mode needed to implement (CMP_CODE X Y).  */
+
+enum machine_mode
+rx_select_cc_mode (enum rtx_code cmp_code, rtx x, rtx y ATTRIBUTE_UNUSED)
+{
+  if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
+    return CC_Fmode;
+
+  switch (cmp_code)
+    {
+    case EQ:
+    case NE:
+    case LT:
+    case GE:
+      return CC_ZSmode;
+    case GT:
+    case LE:
+      return CC_ZSOmode;
+    case GEU:
+    case LTU:
+    case GTU:
+    case LEU:
+      return CC_ZSCmode;
+    default:
+      return CCmode;
+    }
+}
+
 
 #undef  TARGET_FUNCTION_VALUE
 #define TARGET_FUNCTION_VALUE		rx_function_value
diff --git a/gcc/config/rx/rx.h b/gcc/config/rx/rx.h
index 35b5d58..d26c80c 100644
--- a/gcc/config/rx/rx.h
+++ b/gcc/config/rx/rx.h
@@ -624,12 +624,4 @@  extern int rx_float_compare_mode;
 #define BRANCH_COST(SPEED,PREDICT)       1
 #define REGISTER_MOVE_COST(MODE,FROM,TO) 2
 
-#define SELECT_CC_MODE(OP,X,Y)						\
-  (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT ? CC_ZSmode :		\
-    (GET_CODE (X) == PLUS || GET_CODE (X) == MINUS ? CC_ZSCmode :	\
-    (GET_CODE (X) == ABS ? CC_ZSOmode :					\
-    (GET_CODE (X) == AND || GET_CODE (X) == NOT || GET_CODE (X) == IOR	\
-     || GET_CODE (X) == XOR || GET_CODE (X) == ROTATE			\
-     || GET_CODE (X) == ROTATERT || GET_CODE (X) == ASHIFTRT		\
-     || GET_CODE (X) == LSHIFTRT || GET_CODE (X) == ASHIFT ? CC_ZSmode : \
-     CCmode))))
+#define SELECT_CC_MODE(OP,X,Y)  rx_select_cc_mode(OP, X, Y)