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] ns32k: Implement NOTICE_UPDATE_CC using a function.


Hi,

Attached is a patch to implement NOTICE_UPDATE_CC using a function as
a huge macro in a header file is a bit ugly.

Built cc1 with no new warning.  OK to apply?

Kazu Hirata

2004-03-06  Kazu Hirata  <kazu@cs.umass.edu>

	* config/ns32k/ns32k-protos.h: Add a prototype for
	ns32k_notice_update_cc.
	* config/ns32k/ns32k.c (ns32k_notice_update_cc): New.
	* config/ns32k/ns32k.h (NOTICE_UPDATE_CC): Call
	ns32k_notice_update_cc.

Index: ns32k-protos.h
===================================================================
RCS file: /home/kazu/nobackup/gcc-cvs/gcc/gcc/config/ns32k/ns32k-protos.h,v
retrieving revision 1.6
diff -u -r1.6 ns32k-protos.h
--- ns32k-protos.h	5 Dec 2003 09:38:33 -0000	1.6
+++ ns32k-protos.h	6 Mar 2004 21:08:43 -0000
@@ -34,6 +34,7 @@
 extern const char *output_move_double (rtx *);
 extern const char *output_shift_insn (rtx *);
 extern int symbolic_reference_mentioned_p (rtx);
+extern void ns32k_notice_update_cc (rtx, rtx);
 #endif /* RTX_CODE */
 
 #ifdef TREE_CODE
Index: ns32k.c
===================================================================
RCS file: /home/kazu/nobackup/gcc-cvs/gcc/gcc/config/ns32k/ns32k.c,v
retrieving revision 1.46
diff -u -r1.46 ns32k.c
--- ns32k.c	4 Feb 2004 20:27:08 -0000	1.46
+++ ns32k.c	6 Mar 2004 21:33:52 -0000
@@ -1567,4 +1567,75 @@
 			int incoming ATTRIBUTE_UNUSED)
 {
   return gen_rtx_REG (Pmode, NS32K_STRUCT_VALUE_REGNUM);
+}
+
+/* Worker function for NOTICE_UPDATE_CC.  */
+
+void
+ns32k_notice_update_cc (rtx exp, rtx insn ATTRIBUTE_UNUSED)
+{
+  if (GET_CODE (exp) == SET)
+    {
+      if (GET_CODE (SET_DEST (exp)) == CC0)
+	{
+	  cc_status.flags = 0;
+	  cc_status.value1 = SET_DEST (exp);
+	  cc_status.value2 = SET_SRC (exp);
+	}
+      else if (GET_CODE (SET_SRC (exp)) == CALL)
+	{
+	  CC_STATUS_INIT;
+	}
+      else if (GET_CODE (SET_DEST (exp)) == REG)
+	{
+	  if (cc_status.value1
+	      && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value1))
+	    cc_status.value1 = 0;
+	  if (cc_status.value2
+	      && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value2))
+	    cc_status.value2 = 0;
+	}
+      else if (GET_CODE (SET_DEST (exp)) == MEM)
+	{
+	  CC_STATUS_INIT;
+	}
+    }
+  else if (GET_CODE (exp) == PARALLEL
+	   && GET_CODE (XVECEXP (exp, 0, 0)) == SET)
+    {
+      if (GET_CODE (SET_DEST (XVECEXP (exp, 0, 0))) == CC0)
+	{
+	  cc_status.flags = 0;
+	  cc_status.value1 = SET_DEST (XVECEXP (exp, 0, 0));
+	  cc_status.value2 = SET_SRC (XVECEXP (exp, 0, 0));
+	}
+      else if (GET_CODE (SET_DEST (XVECEXP (exp, 0, 0))) == REG)
+	{
+	  if (cc_status.value1
+	      && reg_overlap_mentioned_p (SET_DEST (XVECEXP (exp, 0, 0)),
+					  cc_status.value1))
+	    cc_status.value1 = 0;
+	  if (cc_status.value2
+	      && reg_overlap_mentioned_p (SET_DEST (XVECEXP (exp, 0, 0)),
+					  cc_status.value2))
+	    cc_status.value2 = 0;
+	}
+      else if (GET_CODE (SET_DEST (XVECEXP (exp, 0, 0))) == MEM)
+	{
+	  CC_STATUS_INIT;
+	}
+    }
+  else if (GET_CODE (exp) == CALL)
+    {
+      /* all bets are off */
+      CC_STATUS_INIT;
+    }
+  else
+    {
+      /* nothing happens? CC_STATUS_INIT; */
+    }
+  if (cc_status.value1 && GET_CODE (cc_status.value1) == REG
+      && cc_status.value2
+      && reg_overlap_mentioned_p (cc_status.value1, cc_status.value2))
+    abort ();
 }
Index: ns32k.h
===================================================================
RCS file: /home/kazu/nobackup/gcc-cvs/gcc/gcc/config/ns32k/ns32k.h,v
retrieving revision 1.64
diff -u -r1.64 ns32k.h
--- ns32k.h	6 Feb 2004 06:18:33 -0000	1.64
+++ ns32k.h	6 Mar 2004 21:08:16 -0000
@@ -1174,51 +1174,7 @@
    Do not alter them if the instruction would not alter the cc's.  */
 
 #define NOTICE_UPDATE_CC(EXP, INSN) \
-{ if (GET_CODE (EXP) == SET)					\
-    { if (GET_CODE (SET_DEST (EXP)) == CC0)			\
-	{ cc_status.flags = 0;					\
-	  cc_status.value1 = SET_DEST (EXP);			\
-	  cc_status.value2 = SET_SRC (EXP);			\
-	}							\
-      else if (GET_CODE (SET_SRC (EXP)) == CALL)		\
-	{ CC_STATUS_INIT; }					\
-      else if (GET_CODE (SET_DEST (EXP)) == REG)		\
-	{ if (cc_status.value1					\
-	      && reg_overlap_mentioned_p (SET_DEST (EXP), cc_status.value1)) \
-	    cc_status.value1 = 0;				\
-	  if (cc_status.value2					\
-	      && reg_overlap_mentioned_p (SET_DEST (EXP), cc_status.value2)) \
-	    cc_status.value2 = 0;				\
-	}							\
-      else if (GET_CODE (SET_DEST (EXP)) == MEM)		\
-	{ CC_STATUS_INIT; }					\
-    }								\
-  else if (GET_CODE (EXP) == PARALLEL				\
-	   && GET_CODE (XVECEXP (EXP, 0, 0)) == SET)		\
-    { if (GET_CODE (SET_DEST (XVECEXP (EXP, 0, 0))) == CC0)	\
-	{ cc_status.flags = 0;					\
-	  cc_status.value1 = SET_DEST (XVECEXP (EXP, 0, 0));	\
-	  cc_status.value2 = SET_SRC (XVECEXP (EXP, 0, 0));	\
-	}							\
-      else if (GET_CODE (SET_DEST (XVECEXP (EXP, 0, 0))) == REG) \
-	{ if (cc_status.value1					\
-	      && reg_overlap_mentioned_p (SET_DEST (XVECEXP (EXP, 0, 0)), cc_status.value1)) \
-	    cc_status.value1 = 0;				\
-	  if (cc_status.value2					\
-	      && reg_overlap_mentioned_p (SET_DEST (XVECEXP (EXP, 0, 0)), cc_status.value2)) \
-	    cc_status.value2 = 0;				\
-	}							\
-      else if (GET_CODE (SET_DEST (XVECEXP (EXP, 0, 0))) == MEM) \
-	{ CC_STATUS_INIT; }					\
-    }								\
-  else if (GET_CODE (EXP) == CALL)				\
-    { /* all bets are off */ CC_STATUS_INIT; }			\
-  else { /* nothing happens? CC_STATUS_INIT; */}		\
-  if (cc_status.value1 && GET_CODE (cc_status.value1) == REG	\
-      && cc_status.value2					\
-      && reg_overlap_mentioned_p (cc_status.value1, cc_status.value2))	\
-    abort ();			\
-}
+  ns32k_notice_update_cc ((EXP), (INSN))
 
 /* Describe the costs of the following register moves which are discouraged:
    1.) Moves between the Floating point registers and the frame pointer and stack pointer


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