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]

Re: [patch] m68k.c: Fix build.


Hi,

On Tue, 12 Jun 2007, Kazu Hirata wrote:

> Notice that REGNO_OK_FOR_BASE_P uses reg_renumber. 
[...]
> 
> Index: gcc/config/m68k/m68k.c
> ===================================================================
> --- gcc/config/m68k/m68k.c	(revision 125636)
> +++ gcc/config/m68k/m68k.c	(working copy)
> @@ -4206,7 +4206,12 @@ m68k_output_mi_thunk (FILE *file, tree t
>    insn = get_insns ();
>    split_all_insns_noflow ();
>    final_start_function (insn, file, 1);
> +  max_regno = max_reg_num ();
> +  reg_renumber = xmalloc (max_regno * sizeof (short));
> +  memset (reg_renumber, -1, max_regno * sizeof (short));
>    final (insn, file, 1);
> +  free (reg_renumber);
> +  reg_renumber = 0;
>    final_end_function ();

This looks wrong, I think it'd be better to clean up ADDRESS_REG_P as in 
the (not fully tested) patch below.

bye, Roman


---
 gcc/config/m68k/m68k.c |    4 ++--
 gcc/config/m68k/m68k.h |   23 ++++++++++++++---------
 2 files changed, 16 insertions(+), 11 deletions(-)

Index: egcs/gcc/config/m68k/m68k.c
===================================================================
--- egcs.orig/gcc/config/m68k/m68k.c
+++ egcs/gcc/config/m68k/m68k.c
@@ -1551,7 +1551,7 @@ m68k_legitimate_base_reg_p (rtx x, bool 
   return (REG_P (x)
 	  && (strict_p
 	      ? REGNO_OK_FOR_BASE_P (REGNO (x))
-	      : !DATA_REGNO_P (REGNO (x)) && !FP_REGNO_P (REGNO (x))));
+	      : REGNO_OK_FOR_BASE_NONSTRICT_P (REGNO (x))));
 }
 
 /* Return true if X is a legitimate index register.  STRICT_P says
@@ -1566,7 +1566,7 @@ m68k_legitimate_index_reg_p (rtx x, bool
   return (REG_P (x)
 	  && (strict_p
 	      ? REGNO_OK_FOR_INDEX_P (REGNO (x))
-	      : !FP_REGNO_P (REGNO (x))));
+	      : REGNO_OK_FOR_INDEX_NONSTRICT_P (REGNO (x))));
 }
 
 /* Return true if X is a legitimate index expression for a (d8,An,Xn) or
Index: egcs/gcc/config/m68k/m68k.h
===================================================================
--- egcs.orig/gcc/config/m68k/m68k.h
+++ egcs/gcc/config/m68k/m68k.h
@@ -722,16 +722,16 @@ __transfer_from_trampoline ()					\
 /* Macros to check register numbers against specific register classes.  */
 
 /* True for data registers, D0 through D7.  */
-#define DATA_REGNO_P(REGNO) ((unsigned int) (REGNO) < 8)
+#define DATA_REGNO_P(REGNO)	IN_RANGE (REGNO, 0, 7)
 
 /* True for address registers, A0 through A7.  */
-#define ADDRESS_REGNO_P(REGNO) (((unsigned int) (REGNO) - 8) < 8)
+#define ADDRESS_REGNO_P(REGNO)	IN_RANGE (REGNO, 8, 15)
 
 /* True for integer registers, D0 through D7 and A0 through A7.  */
-#define INT_REGNO_P(REGNO) ((unsigned int) (REGNO) < 16)
+#define INT_REGNO_P(REGNO)	IN_RANGE (REGNO, 0, 15)
 
 /* True for floating point registers, FP0 through FP7.  */
-#define FP_REGNO_P(REGNO) (((unsigned int) (REGNO) - 16) < 8)
+#define FP_REGNO_P(REGNO)	IN_RANGE (REGNO, 16, 23)
 
 #define REGNO_OK_FOR_INDEX_P(REGNO)			\
   (INT_REGNO_P (REGNO)					\
@@ -741,9 +741,14 @@ __transfer_from_trampoline ()					\
   (ADDRESS_REGNO_P (REGNO)				\
    || ADDRESS_REGNO_P (reg_renumber[REGNO]))
 
-#define REGNO_OK_FOR_DATA_P(REGNO)			\
-  (DATA_REGNO_P (REGNO)					\
-   || DATA_REGNO_P (reg_renumber[REGNO]))
+#define REGNO_OK_FOR_INDEX_NONSTRICT_P(REGNO)		\
+  (INT_REGNO_P (REGNO)					\
+   || REGNO >= FIRST_PSEUDO_REGISTER)
+
+#define REGNO_OK_FOR_BASE_NONSTRICT_P(REGNO)		\
+  (ADDRESS_REGNO_P (REGNO)				\
+   || REGNO == ARG_POINTER_REGNUM			\
+   || REGNO >= FIRST_PSEUDO_REGISTER)
 
 /* Now macros that check whether X is a register and also,
    strictly, whether it is in a specified class.
@@ -753,13 +758,13 @@ __transfer_from_trampoline ()					\
    define_optimization.  */
 
 /* 1 if X is a data register.  */
-#define DATA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_DATA_P (REGNO (X)))
+#define DATA_REG_P(X)	(REG_P (X) && DATA_REGNO_P (REGNO (X)))
 
 /* 1 if X is an fp register.  */
 #define FP_REG_P(X)	(REG_P (X) && FP_REGNO_P (REGNO (X)))
 
 /* 1 if X is an address register  */
-#define ADDRESS_REG_P(X) (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X)))
+#define ADDRESS_REG_P(X) (REG_P (X) && ADDRESS_REGNO_P (REGNO (X)))
 
 /* True if SYMBOL + OFFSET constants must refer to something within
    SYMBOL's section.  */


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