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]

[addrmodes] More APIs in addresses.h


This patch grows a "_strict" suffix to the strict functions, and adds a generic function that works in both strict and non-strict modes. The idea is to use this in target C files where REG_STRICT_P is passed from the target header. It will replace stuff like:

  if (REG_P (x)
      && (strict
          ? STRICT_REG_OK_FOR_BASE_P (x)
          : NONSTRICT_REG_OK_FOR_BASE_P (x)))
    return true;

with

  if (ok_for_base_p (x, strict))
    return true;

Each target will have to be looked at individually because of quirks in the current definitions of REG_OK_FOR_BASE_P. In some cases, hard registers that are valid "non-strict" base registers may become invalid when the strict definitions are used.

Again, barring quirks in the target macros, there should be no impact on generated assembly.

Paolo
2006-08-21  Paolo Bonzini  <bonzini@gnu.org>

	* addresses.h (regno_ok_for_base_p, ok_for_base_p, regno_ok_for_index_p,
	ok_for_index_p): Get an argument to indicate strictness.
	(regno_ok_for_base_p_strict, ok_for_base_p_strict, regno_ok_for_index_p_strict,
	ok_for_index_p_strict): New functions.
	* reload.c (find_reloads_address, find_reloads_address_1): Add _strict to calls.
	* regrename.c (scan_rtx_address, replace_oldest_value_addr): Likewise.

	* addresses.h (ok_for_base_p, ok_for_index_p, ok_for_base_p_strict,
	ok_for_index_p_strict, ok_for_base_p_nonstrict, ok_for_index_p_nonstrict): Accept
	non-REG arguments.

Index: addresses.h
===================================================================
--- addresses.h	(revision 116293)
+++ addresses.h	(working copy)
@@ -34,11 +34,11 @@ base_reg_class (enum machine_mode mode A
    complete.  Arguments as for the called function.  */
 
 static inline bool
-regno_ok_for_base_p (unsigned regno, enum machine_mode mode ATTRIBUTE_UNUSED,
-		     enum rtx_code outer_code ATTRIBUTE_UNUSED,
-		     enum rtx_code index_code ATTRIBUTE_UNUSED)
+regno_ok_for_base_p_strict (unsigned regno, enum machine_mode mode ATTRIBUTE_UNUSED,
+			    enum rtx_code outer_code ATTRIBUTE_UNUSED,
+			    enum rtx_code index_code ATTRIBUTE_UNUSED)
 {
-  if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0)
+  if (regno >= FIRST_PSEUDO_REGISTER)
     {
       if (reg_renumber[regno] >= 0)
         regno = reg_renumber[regno];
@@ -53,12 +53,15 @@ regno_ok_for_base_p (unsigned regno, enu
    complete.  Arguments as for the called function.  */
 
 static inline bool
-ok_for_base_p (rtx reg, enum machine_mode mode ATTRIBUTE_UNUSED,
-               enum rtx_code outer_code ATTRIBUTE_UNUSED,
-               enum rtx_code index_code ATTRIBUTE_UNUSED)
-{
-  unsigned regno = REGNO (reg);
-  if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0)
+ok_for_base_p_strict (rtx reg, enum machine_mode mode ATTRIBUTE_UNUSED,
+	              enum rtx_code outer_code ATTRIBUTE_UNUSED,
+	              enum rtx_code index_code ATTRIBUTE_UNUSED)
+{
+  unsigned regno;
+  if (!REG_P (reg))
+    return false;
+  regno = REGNO (reg);
+  if (regno >= FIRST_PSEUDO_REGISTER)
     {
       if (reg_renumber[regno] >= 0)
         regno = reg_renumber[regno];
@@ -91,7 +94,10 @@ ok_for_base_p_nonstrict (rtx reg, enum m
 	                 enum rtx_code outer_code ATTRIBUTE_UNUSED,
 	                 enum rtx_code index_code ATTRIBUTE_UNUSED)
 {
-  unsigned regno = REGNO (reg);
+  unsigned regno;
+  if (!REG_P (reg))
+    return false;
+  regno = REGNO (reg);
   if (regno >= FIRST_PSEUDO_REGISTER)
     return true;
 
@@ -103,7 +109,7 @@ ok_for_base_p_nonstrict (rtx reg, enum m
    complete.  Arguments as for REGNO_OK_FOR_INDEX_P.  */
 
 static inline bool
-regno_ok_for_index_p (unsigned regno)
+regno_ok_for_index_p_strict (unsigned regno)
 {
   if (regno >= FIRST_PSEUDO_REGISTER)
     {
@@ -120,9 +126,12 @@ regno_ok_for_index_p (unsigned regno)
    complete.  Arguments as for REGNO_OK_FOR_INDEX_P.  */
 
 static inline bool
-ok_for_index_p (rtx reg)
+ok_for_index_p_strict (rtx reg)
 {
-  unsigned regno = REGNO (reg);
+  unsigned regno;
+  if (!REG_P (reg))
+    return false;
+  regno = REGNO (reg);
   if (regno >= FIRST_PSEUDO_REGISTER)
     {
       if (reg_renumber[regno] >= 0)
@@ -148,9 +157,95 @@ regno_ok_for_index_p_nonstrict (unsigned
 static inline bool
 ok_for_index_p_nonstrict (rtx reg)
 {
-  unsigned regno = REGNO (reg);
+  unsigned regno;
+  if (!REG_P (reg))
+    return false;
+  regno = REGNO (reg);
   return regno >= FIRST_PSEUDO_REGISTER
 	 || REGNO_OK_FOR_INDEX_P (regno);
 }  
 
+
+/* Wrapper around REGNO_MODE_CODE_OK_FOR_BASE_P, for use after register allocation is
+   complete.  Arguments as for the called function.  */
+
+static inline bool
+regno_ok_for_base_p (unsigned regno, enum machine_mode mode ATTRIBUTE_UNUSED,
+		     enum rtx_code outer_code ATTRIBUTE_UNUSED,
+		     enum rtx_code index_code ATTRIBUTE_UNUSED,
+		     int strict_p)
+{
+  if (regno >= FIRST_PSEUDO_REGISTER)
+    {
+      if (strict_p && reg_renumber[regno] >= 0)
+        regno = reg_renumber[regno];
+      else
+        return !strict_p;
+    }
+
+  return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, mode, outer_code, index_code);
+}
+
+/* Wrapper around REGNO_MODE_CODE_OK_FOR_BASE_P, for use after register allocation is
+   complete.  Arguments as for the called function.  */
+
+static inline bool
+ok_for_base_p (rtx reg, enum machine_mode mode ATTRIBUTE_UNUSED,
+	       enum rtx_code outer_code ATTRIBUTE_UNUSED,
+	       enum rtx_code index_code ATTRIBUTE_UNUSED,
+	       int strict_p)
+{
+  unsigned regno;
+  if (!REG_P (reg))
+    return false;
+  regno = REGNO (reg);
+  if (regno >= FIRST_PSEUDO_REGISTER)
+    {
+      if (strict_p && reg_renumber[regno] >= 0)
+        regno = reg_renumber[regno];
+      else
+        return !strict_p;
+    }
+
+  return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, mode, outer_code, index_code);
+}
+
+  
+/* Wrapper around REGNO_OK_FOR_INDEX_P, for use after register allocation is
+   complete.  Arguments as for REGNO_OK_FOR_INDEX_P.  */
+
+static inline bool
+regno_ok_for_index_p (unsigned regno, int strict_p)
+{
+  if (regno >= FIRST_PSEUDO_REGISTER)
+    {
+      if (strict_p && reg_renumber[regno] >= 0)
+        regno = reg_renumber[regno];
+      else
+        return !strict_p;
+    }
+
+  return REGNO_OK_FOR_INDEX_P (regno);
+}
+
+/* Wrapper around REGNO_OK_FOR_INDEX_P, for use after register allocation is
+   complete.  Arguments as for REGNO_OK_FOR_INDEX_P.  */
+
+static inline bool
+ok_for_index_p (rtx reg, int strict_p)
+{
+  unsigned regno;
+  if (!REG_P (reg))
+    return false;
+  regno = REGNO (reg);
+  if (regno >= FIRST_PSEUDO_REGISTER)
+    {
+      if (strict_p && reg_renumber[regno] >= 0)
+        regno = reg_renumber[regno];
+      else
+        return !strict_p;
+    }
+
+  return REGNO_OK_FOR_INDEX_P (regno);
+}
 
Index: reload.c
===================================================================
--- reload.c	(revision 116289)
+++ reload.c	(working copy)
@@ -4829,7 +4829,7 @@ find_reloads_address (enum machine_mode 
 	 subject of a CLOBBER in this insn.  */
 
       else if (regno < FIRST_PSEUDO_REGISTER
-	       && regno_ok_for_base_p (regno, mode, MEM, SCRATCH)
+	       && regno_ok_for_base_p_strict (regno, mode, MEM, SCRATCH)
 	       && ! regno_clobbered_p (regno, this_insn, mode, 0))
 	return 0;
 
@@ -4953,7 +4953,7 @@ find_reloads_address (enum machine_mode 
 	   && REG_P (XEXP (ad, 0))
 	   && REGNO (XEXP (ad, 0)) < FIRST_PSEUDO_REGISTER
 	   && GET_CODE (XEXP (ad, 1)) == CONST_INT
-	   && regno_ok_for_base_p (REGNO (XEXP (ad, 0)), mode, PLUS,
+	   && regno_ok_for_base_p_strict (REGNO (XEXP (ad, 0)), mode, PLUS,
 				   CONST_INT))
 
     {
@@ -5036,8 +5036,8 @@ find_reloads_address (enum machine_mode 
 
       addend = XEXP (XEXP (ad, 0), 1 - op_index);
 
-      if ((regno_ok_for_base_p (REGNO (operand), mode, inner_code,
-				GET_CODE (addend))
+      if ((regno_ok_for_base_p_strict (REGNO (operand), mode, inner_code,
+				       GET_CODE (addend))
 	   || operand == frame_pointer_rtx
 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
 	   || operand == hard_frame_pointer_rtx
@@ -5366,8 +5366,8 @@ find_reloads_address_1 (enum machine_mod
 {
 #define REG_OK_FOR_CONTEXT(CONTEXT, REGNO, MODE, OUTER, INDEX)		\
   ((CONTEXT) == 0							\
-   ? regno_ok_for_base_p (REGNO, MODE, OUTER, INDEX)			\
-   : REGNO_OK_FOR_INDEX_P (REGNO))					
+   ? regno_ok_for_base_p_strict (REGNO, MODE, OUTER, INDEX)			\
+   : regno_ok_for_index_p_strict (REGNO))					
 
   enum reg_class context_reg_class;
   RTX_CODE code = GET_CODE (x);
@@ -5465,25 +5465,25 @@ find_reloads_address_1 (enum machine_mod
 
 	else if (code0 == REG && code1 == REG)
 	  {
-	    if (REGNO_OK_FOR_INDEX_P (REGNO (op0))
-		&& regno_ok_for_base_p (REGNO (op1), mode, PLUS, REG))
+	    if (regno_ok_for_index_p_strict (REGNO (op0))
+		&& regno_ok_for_base_p_strict (REGNO (op1), mode, PLUS, REG))
 	      return 0;
-	    else if (REGNO_OK_FOR_INDEX_P (REGNO (op1))
-		     && regno_ok_for_base_p (REGNO (op0), mode, PLUS, REG))
+	    else if (regno_ok_for_index_p_strict (REGNO (op1))
+		     && regno_ok_for_base_p_strict (REGNO (op0), mode, PLUS, REG))
 	      return 0;
-	    else if (regno_ok_for_base_p (REGNO (op1), mode, PLUS, REG))
+	    else if (regno_ok_for_base_p_strict (REGNO (op1), mode, PLUS, REG))
 	      find_reloads_address_1 (mode, orig_op0, 1, PLUS, SCRATCH,
 				      &XEXP (x, 0), opnum, type, ind_levels,
 				      insn);
-	    else if (regno_ok_for_base_p (REGNO (op0), mode, PLUS, REG))
+	    else if (regno_ok_for_base_p_strict (REGNO (op0), mode, PLUS, REG))
 	      find_reloads_address_1 (mode, orig_op1, 1, PLUS, SCRATCH,
 				      &XEXP (x, 1), opnum, type, ind_levels,
 				      insn);
-	    else if (REGNO_OK_FOR_INDEX_P (REGNO (op1)))
+	    else if (regno_ok_for_index_p_strict (REGNO (op1)))
 	      find_reloads_address_1 (mode, orig_op0, 0, PLUS, REG,
 				      &XEXP (x, 0), opnum, type, ind_levels,
 				      insn);
-	    else if (REGNO_OK_FOR_INDEX_P (REGNO (op0)))
+	    else if (regno_ok_for_index_p_strict (REGNO (op0)))
 	      find_reloads_address_1 (mode, orig_op1, 0, PLUS, REG,
 				      &XEXP (x, 1), opnum, type, ind_levels,
 				      insn);
@@ -5544,7 +5544,7 @@ find_reloads_address_1 (enum machine_mod
 	   auto-modify by a constant then we could try replacing a pseudo
 	   register with its equivalent constant where applicable.  */
 	if (REG_P (XEXP (op1, 1)))
-	  if (!REGNO_OK_FOR_INDEX_P (REGNO (XEXP (op1, 1))))
+	  if (!regno_ok_for_index_p_strict (REGNO (XEXP (op1, 1))))
 	    find_reloads_address_1 (mode, XEXP (op1, 1), 1, code, SCRATCH,
 				    &XEXP (op1, 1), opnum, type, ind_levels,
 				    insn);
@@ -5601,7 +5601,7 @@ find_reloads_address_1 (enum machine_mod
 	  regno = reg_renumber[regno];
 
 	/* We require a base register here...  */
-	if (!regno_ok_for_base_p (regno, GET_MODE (x), code, index_code))
+	if (!regno_ok_for_base_p_strict (regno, GET_MODE (x), code, index_code))
 	  {
 	    reloadnum = push_reload (XEXP (op1, 0), XEXP (x, 0),
 				     &XEXP (op1, 0), &XEXP (x, 0),
Index: regrename.c
===================================================================
--- regrename.c	(revision 116286)
+++ regrename.c	(working copy)
@@ -574,17 +574,17 @@ scan_rtx_address (rtx insn, rtx *loc, en
 	    int index_op;
 	    unsigned regno0 = REGNO (op0), regno1 = REGNO (op1);
 
-	    if (REGNO_OK_FOR_INDEX_P (regno0)
-		&& regno_ok_for_base_p (regno1, mode, PLUS, REG))
+	    if (regno_ok_for_index_p_strict (regno0)
+		&& regno_ok_for_base_p_strict (regno1, mode, PLUS, REG))
 	      index_op = 0;
-	    else if (REGNO_OK_FOR_INDEX_P (regno1)
-		     && regno_ok_for_base_p (regno0, mode, PLUS, REG))
+	    else if (regno_ok_for_index_p_strict (regno1)
+		     && regno_ok_for_base_p_strict (regno0, mode, PLUS, REG))
 	      index_op = 1;
-	    else if (regno_ok_for_base_p (regno1, mode, PLUS, REG))
+	    else if (regno_ok_for_base_p_strict (regno1, mode, PLUS, REG))
 	      index_op = 0;
-	    else if (regno_ok_for_base_p (regno0, mode, PLUS, REG))
+	    else if (regno_ok_for_base_p_strict (regno0, mode, PLUS, REG))
 	      index_op = 1;
-	    else if (REGNO_OK_FOR_INDEX_P (regno1))
+	    else if (regno_ok_for_index_p_strict (regno1))
 	      index_op = 1;
 	    else
 	      index_op = 0;
@@ -1498,17 +1498,17 @@ replace_oldest_value_addr (rtx *loc, enu
 	    int index_op;
 	    unsigned regno0 = REGNO (op0), regno1 = REGNO (op1);
 
-	    if (REGNO_OK_FOR_INDEX_P (regno0)
-		&& regno_ok_for_base_p (regno1, mode, PLUS, REG))
+	    if (regno_ok_for_index_p_strict (regno0)
+		&& regno_ok_for_base_p_strict (regno1, mode, PLUS, REG))
 	      index_op = 0;
-	    else if (REGNO_OK_FOR_INDEX_P (regno1)
-		     && regno_ok_for_base_p (regno0, mode, PLUS, REG))
+	    else if (regno_ok_for_index_p_strict (regno1)
+		     && regno_ok_for_base_p_strict (regno0, mode, PLUS, REG))
 	      index_op = 1;
-	    else if (regno_ok_for_base_p (regno1, mode, PLUS, REG))
+	    else if (regno_ok_for_base_p_strict (regno1, mode, PLUS, REG))
 	      index_op = 0;
-	    else if (regno_ok_for_base_p (regno0, mode, PLUS, REG))
+	    else if (regno_ok_for_base_p_strict (regno0, mode, PLUS, REG))
 	      index_op = 1;
-	    else if (REGNO_OK_FOR_INDEX_P (regno1))
+	    else if (regno_ok_for_index_p_strict (regno1))
 	      index_op = 1;
 	    else
 	      index_op = 0;

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