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] pdp11: Add TARGET_LEGITIMATE_ADDRESS_P hook


This match replaces GO_IF_LEGITIMATE_ADDRESS by the equivalent as a target hook.

Tested by build and make check; committed.

	paul

ChangeLog:

2010-11-21  Paul Koning  <ni1d@arrl.net>

	* config/mips/pdp11.c (pdp11_legitimate_address_p): New function.
	* config/mips/pdp11.h (GO_IF_LEGITIMATE_ADDRESS): Delete.

Index: config/pdp11/pdp11.c
===================================================================
--- config/pdp11/pdp11.c	(revision 166978)
+++ config/pdp11/pdp11.c	(working copy)
@@ -227,6 +227,9 @@
 
 #undef  TARGET_PREFERRED_OUTPUT_RELOAD_CLASS
 #define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS pdp11_preferred_output_reload_class
+
+#undef  TARGET_LEGITIMATE_ADDRESS_P
+#define TARGET_LEGITIMATE_ADDRESS_P pdp11_legitimate_address_p
 
 /* Implement TARGET_HANDLE_OPTION.  */
 
@@ -1706,6 +1709,115 @@
   return (fromfloat != tofloat);
 }
 
+/* TARGET_LEGITIMATE_ADDRESS_P recognizes an RTL expression
+   that is a valid memory address for an instruction.
+   The MODE argument is the machine mode for the MEM expression
+   that wants to use this address.
+
+*/
+
+static bool
+pdp11_legitimate_address_p (enum machine_mode mode,
+			    rtx operand, bool strict)
+{
+    rtx xfoob;
+
+    /* accept @#address */
+    if (CONSTANT_ADDRESS_P (operand))
+      return true;
+    
+    switch (GET_CODE (operand))
+      {
+      case REG:
+	/* accept (R0) */
+	return !strict || REGNO_OK_FOR_BASE_P (REGNO (operand));
+    
+      case PLUS:
+	/* accept X(R0) */
+	return GET_CODE (XEXP (operand, 0)) == REG
+	  && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (operand, 0))))
+	  && CONSTANT_ADDRESS_P (XEXP (operand, 1));
+
+      case PRE_DEC:
+	/* accept -(R0) */
+	return GET_CODE (XEXP (operand, 0)) == REG
+	  && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (operand, 0))));
+
+      case POST_INC:
+	/* accept (R0)+ */
+	return GET_CODE (XEXP (operand, 0)) == REG
+	  && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (operand, 0))));
+
+      case PRE_MODIFY:
+	/* accept -(SP) -- which uses PRE_MODIFY for byte mode */
+	return GET_CODE (XEXP (operand, 0)) == REG
+	  && REGNO (XEXP (operand, 0)) == STACK_POINTER_REGNUM
+	  && GET_CODE ((xfoob = XEXP (operand, 1))) == PLUS
+	  && GET_CODE (XEXP (xfoob, 0)) == REG
+	  && REGNO (XEXP (xfoob, 0)) == STACK_POINTER_REGNUM
+	  && CONSTANT_P (XEXP (xfoob, 1))
+	  && INTVAL (XEXP (xfoob,1)) == -2;
+
+      case POST_MODIFY:
+	/* accept (SP)+ -- which uses POST_MODIFY for byte mode */
+	return GET_CODE (XEXP (operand, 0)) == REG
+	  && REGNO (XEXP (operand, 0)) == STACK_POINTER_REGNUM
+	  && GET_CODE ((xfoob = XEXP (operand, 1))) == PLUS
+	  && GET_CODE (XEXP (xfoob, 0)) == REG
+	  && REGNO (XEXP (xfoob, 0)) == STACK_POINTER_REGNUM
+	  && CONSTANT_P (XEXP (xfoob, 1))
+	  && INTVAL (XEXP (xfoob,1)) == 2;
+
+      case MEM:
+	/* handle another level of indirection ! */
+	xfoob = XEXP (operand, 0);
+
+	/* (MEM:xx (MEM:xx ())) is not valid for SI, DI and currently
+	   also forbidden for float, because we have to handle this 
+	   in output_move_double and/or output_move_quad() - we could
+	   do it, but currently it's not worth it!!! 
+	   now that DFmode cannot go into CPU register file, 
+	   maybe I should allow float ... 
+	   but then I have to handle memory-to-memory moves in movdf ??  */
+	if (GET_MODE_BITSIZE(mode) > 16)
+	  return false;
+
+	/* accept @address */
+	if (CONSTANT_ADDRESS_P (xfoob))
+	  return true;
+
+	switch (GET_CODE (xfoob))
+	  {
+	  case REG:
+	    /* accept @(R0) - which is @0(R0) */
+	    return !strict || REGNO_OK_FOR_BASE_P(REGNO (xfoob));
+
+	  case PLUS:
+	    /* accept @X(R0) */
+	    return GET_CODE (XEXP (xfoob, 0)) == REG
+	      && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (xfoob, 0))))
+	      && CONSTANT_ADDRESS_P (XEXP (xfoob, 1));
+
+	  case PRE_DEC:
+	    /* accept @-(R0) */
+	    return GET_CODE (XEXP (xfoob, 0)) == REG
+	      && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (xfoob, 0))));
+
+	  case POST_INC:
+	    /* accept @(R0)+ */
+	    return GET_CODE (XEXP (xfoob, 0)) == REG
+	      && (!strict || REGNO_OK_FOR_BASE_P (REGNO (XEXP (xfoob, 0))));
+
+	  default:
+	    /* anything else is invalid */
+	    return false;
+	  }
+
+      default:
+	/* anything else is invalid */
+	return false;
+      }
+}
 /* Return the class number of the smallest class containing
    reg number REGNO.  */
 enum reg_class
@@ -1919,7 +2031,7 @@
 static bool
 pdp11_function_value_regno_p (const unsigned int regno)
 {
-  return (regno == 0) || (TARGET_AC0 && (regno == 8));
+  return (regno == RETVAL_REGNUM) || (TARGET_AC0 && (regno == AC0_REGNUM));
 }
 
 /* Worker function for TARGET_TRAMPOLINE_INIT.
Index: config/pdp11/pdp11.h
===================================================================
--- config/pdp11/pdp11.h	(revision 166978)
+++ config/pdp11/pdp11.h	(working copy)
@@ -500,118 +500,6 @@
 
 #endif
 
-/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
-   that is a valid memory address for an instruction.
-   The MODE argument is the machine mode for the MEM expression
-   that wants to use this address.
-
-*/
-
-#define GO_IF_LEGITIMATE_ADDRESS(mode, operand, ADDR) \
-{						      \
-    rtx xfoob;								\
-									\
-    /* accept (R0) */							\
-    if (GET_CODE (operand) == REG					\
-	&& REG_OK_FOR_BASE_P(operand))					\
-      goto ADDR;							\
-									\
-    /* accept @#address */						\
-    if (CONSTANT_ADDRESS_P (operand))					\
-      goto ADDR;							\
-    									\
-    /* accept X(R0) */							\
-    if (GET_CODE (operand) == PLUS       				\
-	&& GET_CODE (XEXP (operand, 0)) == REG				\
-	&& REG_OK_FOR_BASE_P (XEXP (operand, 0))			\
-	&& CONSTANT_ADDRESS_P (XEXP (operand, 1)))			\
-      goto ADDR;							\
-    									\
-    /* accept -(R0) */							\
-    if (GET_CODE (operand) == PRE_DEC					\
-	&& GET_CODE (XEXP (operand, 0)) == REG				\
-	&& REG_OK_FOR_BASE_P (XEXP (operand, 0)))			\
-      goto ADDR;							\
-									\
-    /* accept (R0)+ */							\
-    if (GET_CODE (operand) == POST_INC					\
-	&& GET_CODE (XEXP (operand, 0)) == REG				\
-	&& REG_OK_FOR_BASE_P (XEXP (operand, 0)))			\
-      goto ADDR;							\
-									\
-    /* accept -(SP) -- which uses PRE_MODIFY for byte mode */		\
-    if (GET_CODE (operand) == PRE_MODIFY				\
-	&& GET_CODE (XEXP (operand, 0)) == REG				\
-	&& REGNO (XEXP (operand, 0)) == STACK_POINTER_REGNUM       	\
-	&& GET_CODE ((xfoob = XEXP (operand, 1))) == PLUS		\
-	&& GET_CODE (XEXP (xfoob, 0)) == REG				\
-	&& REGNO (XEXP (xfoob, 0)) == STACK_POINTER_REGNUM       	\
-	&& CONSTANT_P (XEXP (xfoob, 1))                                 \
-	&& INTVAL (XEXP (xfoob,1)) == -2)      	               		\
-      goto ADDR;							\
-									\
-    /* accept (SP)+ -- which uses POST_MODIFY for byte mode */		\
-    if (GET_CODE (operand) == POST_MODIFY				\
-	&& GET_CODE (XEXP (operand, 0)) == REG				\
-	&& REGNO (XEXP (operand, 0)) == STACK_POINTER_REGNUM       	\
-	&& GET_CODE ((xfoob = XEXP (operand, 1))) == PLUS		\
-	&& GET_CODE (XEXP (xfoob, 0)) == REG				\
-	&& REGNO (XEXP (xfoob, 0)) == STACK_POINTER_REGNUM		\
-	&& CONSTANT_P (XEXP (xfoob, 1))                                 \
-	&& INTVAL (XEXP (xfoob,1)) == 2)      	               		\
-      goto ADDR;							\
-									\
-    									\
-    /* handle another level of indirection ! */				\
-    if (GET_CODE(operand) != MEM)					\
-      goto fail;							\
-									\
-    xfoob = XEXP (operand, 0);						\
-									\
-    /* (MEM:xx (MEM:xx ())) is not valid for SI, DI and currently */    \
-    /* also forbidden for float, because we have to handle this */  	\
-    /* in output_move_double and/or output_move_quad() - we could */   	\
-    /* do it, but currently it's not worth it!!! */			\
-    /* now that DFmode cannot go into CPU register file, */		\
-    /* maybe I should allow float ... */				\
-    /*  but then I have to handle memory-to-memory moves in movdf ?? */ \
-									\
-    if (GET_MODE_BITSIZE(mode) > 16)					\
-      goto fail;							\
-									\
-    /* accept @(R0) - which is @0(R0) */				\
-    if (GET_CODE (xfoob) == REG						\
-	&& REG_OK_FOR_BASE_P(xfoob))					\
-      goto ADDR;							\
-									\
-    /* accept @address */						\
-    if (CONSTANT_ADDRESS_P (xfoob))					\
-      goto ADDR;							\
-    									\
-    /* accept @X(R0) */							\
-    if (GET_CODE (xfoob) == PLUS       					\
-	&& GET_CODE (XEXP (xfoob, 0)) == REG				\
-	&& REG_OK_FOR_BASE_P (XEXP (xfoob, 0))				\
-	&& CONSTANT_ADDRESS_P (XEXP (xfoob, 1)))			\
-      goto ADDR;							\
-									\
-    /* accept @-(R0) */							\
-    if (GET_CODE (xfoob) == PRE_DEC					\
-	&& GET_CODE (XEXP (xfoob, 0)) == REG				\
-	&& REG_OK_FOR_BASE_P (XEXP (xfoob, 0)))				\
-      goto ADDR;							\
-									\
-    /* accept @(R0)+ */							\
-    if (GET_CODE (xfoob) == POST_INC					\
-	&& GET_CODE (XEXP (xfoob, 0)) == REG				\
-	&& REG_OK_FOR_BASE_P (XEXP (xfoob, 0)))				\
-      goto ADDR;							\
-									\
-  /* anything else is invalid */					\
-  fail: ;								\
-}
-
-
 /* Specify the machine mode that this machine uses
    for the index in the tablejump instruction.  */
 #define CASE_VECTOR_MODE HImode


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