diff mbox

[XTENSA] Hookize GO_IF_MODE_DEPENDENT_ADDRESS

Message ID 1213888183.20110116170319@post.ru
State New
Headers show

Commit Message

Anatoly Sokolov Jan. 16, 2011, 2:03 p.m. UTC
Hello.

  This patch removes obsolete GO_IF_MODE_DEPENDENT_ADDRESS macros from XTENSA 
back end in the GCC and introduces equivalent TARGET_MODE_DEPENDENT_ADDRESS_P 
target hook.

  Not tested.

  OK to install?

        * config/xtensa/xtensa.h (GO_IF_MODE_DEPENDENT_ADDRESS): Remove.
        * config/xtensa/xtensa-protos.h (constantpool_address_p): Remove.
        * config/xtensa/xtensa.c (xtensa_mode_dependent_address_p): New function.
        (TARGET_MODE_DEPENDENT_ADDRESS_P): Define.
        (constantpool_address_p): Make static. Change return type to bool. Change
        argument type to const_rtx. Use CONST_INT_P predicate.



Anatoly.

Comments

Sterling Augustine Jan. 17, 2011, 9:21 p.m. UTC | #1
I'm testing this one today. Will respond tomorrow.

Thanks,

Sterling

On 01/16/2011 06:03 AM, Anatoly Sokolov wrote:
> Hello.
>
>    This patch removes obsolete GO_IF_MODE_DEPENDENT_ADDRESS macros from XTENSA
> back end in the GCC and introduces equivalent TARGET_MODE_DEPENDENT_ADDRESS_P
> target hook.
>
>    Not tested.
>
>    OK to install?
>
>          * config/xtensa/xtensa.h (GO_IF_MODE_DEPENDENT_ADDRESS): Remove.
>          * config/xtensa/xtensa-protos.h (constantpool_address_p): Remove.
>          * config/xtensa/xtensa.c (xtensa_mode_dependent_address_p): New function.
>          (TARGET_MODE_DEPENDENT_ADDRESS_P): Define.
>          (constantpool_address_p): Make static. Change return type to bool. Change
>          argument type to const_rtx. Use CONST_INT_P predicate.
>
> Index: gcc/config/xtensa/xtensa.c
> ===================================================================
> --- gcc/config/xtensa/xtensa.c  (revision 168851)
> +++ gcc/config/xtensa/xtensa.c  (working copy)
> @@ -126,6 +126,7 @@
>   static struct machine_function * xtensa_init_machine_status (void);
>   static rtx xtensa_legitimize_tls_address (rtx);
>   static rtx xtensa_legitimize_address (rtx, rtx, enum machine_mode);
> +static bool xtensa_mode_dependent_address_p (const_rtx);
>   static bool xtensa_return_in_msb (const_tree);
>   static void printx (FILE *, signed int);
>   static void xtensa_function_epilogue (FILE *, HOST_WIDE_INT);
> @@ -161,6 +162,8 @@
>   static void xtensa_trampoline_init (rtx, tree, rtx);
>   static bool xtensa_output_addr_const_extra (FILE *, rtx);
>
> +static bool constantpool_address_p (const_rtx addr);
> +
>   static const int reg_nonleaf_alloc_order[FIRST_PSEUDO_REGISTER] =
>     REG_ALLOC_ORDER;
>
> @@ -201,6 +204,8 @@
>
>   #undef TARGET_LEGITIMIZE_ADDRESS
>   #define TARGET_LEGITIMIZE_ADDRESS xtensa_legitimize_address
> +#undef TARGET_MODE_DEPENDENT_ADDRESS_P
> +#define TARGET_MODE_DEPENDENT_ADDRESS_P xtensa_mode_dependent_address_p
>
>   #undef TARGET_RTX_COSTS
>   #define TARGET_RTX_COSTS xtensa_rtx_costs
> @@ -494,10 +499,10 @@
>   }
>
>
> -int
> -constantpool_address_p (rtx addr)
> +static bool
> +constantpool_address_p (const_rtx addr)
>   {
> -  rtx sym = addr;
> +  const_rtx sym = addr;
>
>     if (GET_CODE (addr) == CONST)
>       {
> @@ -506,21 +511,21 @@
>         /* Only handle (PLUS (SYM, OFFSET)) form.  */
>         addr = XEXP (addr, 0);
>         if (GET_CODE (addr) != PLUS)
> -       return FALSE;
> +       return false;
>
>         /* Make sure the address is word aligned.  */
>         offset = XEXP (addr, 1);
> -      if ((GET_CODE (offset) != CONST_INT)
> +      if ((!CONST_INT_P (offset))
>            || ((INTVAL (offset)&  3) != 0))
> -       return FALSE;
> +       return false;
>
>         sym = XEXP (addr, 0);
>       }
>
>     if ((GET_CODE (sym) == SYMBOL_REF)
>         &&  CONSTANT_POOL_ADDRESS_P (sym))
> -    return TRUE;
> -  return FALSE;
> +    return true;
> +  return false;
>   }
>
>
> @@ -1937,7 +1942,22 @@
>     return x;
>   }
>
> +/* Worker function for TARGET_MODE_DEPENDENT_ADDRESS_P.
>
> +   Treat constant-pool references as "mode dependent" since they can
> +   only be accessed with SImode loads.  This works around a bug in the
> +   combiner where a constant pool reference is temporarily converted
> +   to an HImode load, which is then assumed to zero-extend based on
> +   our definition of LOAD_EXTEND_OP.  This is wrong because the high
> +   bits of a 16-bit value in the constant pool are now sign-extended
> +   by default.  */
> +
> +static bool
> +xtensa_mode_dependent_address_p (const_rtx addr)
> +{
> +  return constantpool_address_p (addr);
> +}
> +
>   /* Helper for xtensa_tls_referenced_p.  */
>
>   static int
> Index: gcc/config/xtensa/xtensa.h
> ===================================================================
> --- gcc/config/xtensa/xtensa.h  (revision 168851)
> +++ gcc/config/xtensa/xtensa.h  (working copy)
> @@ -695,20 +695,6 @@
>      &&  GET_CODE (X) != LABEL_REF                                                \
>      &&  GET_CODE (X) != CONST)
>
> -/* Treat constant-pool references as "mode dependent" since they can
> -   only be accessed with SImode loads.  This works around a bug in the
> -   combiner where a constant pool reference is temporarily converted
> -   to an HImode load, which is then assumed to zero-extend based on
> -   our definition of LOAD_EXTEND_OP.  This is wrong because the high
> -   bits of a 16-bit value in the constant pool are now sign-extended
> -   by default.  */
> -
> -#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)                      \
> -  do {                                                                 \
> -    if (constantpool_address_p (ADDR))                                 \
> -      goto LABEL;                                                      \
> -  } while (0)
> -
>   /* Specify the machine mode that this machine uses
>      for the index in the tablejump instruction.  */
>   #define CASE_VECTOR_MODE (SImode)
> Index: gcc/config/xtensa/xtensa-protos.h
> ===================================================================
> --- gcc/config/xtensa/xtensa-protos.h   (revision 168851)
> +++ gcc/config/xtensa/xtensa-protos.h   (working copy)
> @@ -36,7 +36,6 @@
>   extern int xt_true_regnum (rtx);
>   extern int xtensa_valid_move (enum machine_mode, rtx *);
>   extern int smalloffset_mem_p (rtx);
> -extern int constantpool_address_p (rtx);
>   extern int constantpool_mem_p (rtx);
>   extern void xtensa_extend_reg (rtx, rtx);
>   extern void xtensa_expand_conditional_branch (rtx *, enum machine_mode);
>
>
> Anatoly.
>
Sterling Augustine Jan. 20, 2011, 12:29 a.m. UTC | #2
Approved. Please apply.

Thanks!

Sterling

On 01/16/2011 06:03 AM, Anatoly Sokolov wrote:
> Hello.
>
>    This patch removes obsolete GO_IF_MODE_DEPENDENT_ADDRESS macros from XTENSA
> back end in the GCC and introduces equivalent TARGET_MODE_DEPENDENT_ADDRESS_P
> target hook.
>
>    Not tested.
>
>    OK to install?
>
>          * config/xtensa/xtensa.h (GO_IF_MODE_DEPENDENT_ADDRESS): Remove.
>          * config/xtensa/xtensa-protos.h (constantpool_address_p): Remove.
>          * config/xtensa/xtensa.c (xtensa_mode_dependent_address_p): New function.
>          (TARGET_MODE_DEPENDENT_ADDRESS_P): Define.
>          (constantpool_address_p): Make static. Change return type to bool. Change
>          argument type to const_rtx. Use CONST_INT_P predicate.
>
> Index: gcc/config/xtensa/xtensa.c
> ===================================================================
> --- gcc/config/xtensa/xtensa.c  (revision 168851)
> +++ gcc/config/xtensa/xtensa.c  (working copy)
> @@ -126,6 +126,7 @@
>   static struct machine_function * xtensa_init_machine_status (void);
>   static rtx xtensa_legitimize_tls_address (rtx);
>   static rtx xtensa_legitimize_address (rtx, rtx, enum machine_mode);
> +static bool xtensa_mode_dependent_address_p (const_rtx);
>   static bool xtensa_return_in_msb (const_tree);
>   static void printx (FILE *, signed int);
>   static void xtensa_function_epilogue (FILE *, HOST_WIDE_INT);
> @@ -161,6 +162,8 @@
>   static void xtensa_trampoline_init (rtx, tree, rtx);
>   static bool xtensa_output_addr_const_extra (FILE *, rtx);
>
> +static bool constantpool_address_p (const_rtx addr);
> +
>   static const int reg_nonleaf_alloc_order[FIRST_PSEUDO_REGISTER] =
>     REG_ALLOC_ORDER;
>
> @@ -201,6 +204,8 @@
>
>   #undef TARGET_LEGITIMIZE_ADDRESS
>   #define TARGET_LEGITIMIZE_ADDRESS xtensa_legitimize_address
> +#undef TARGET_MODE_DEPENDENT_ADDRESS_P
> +#define TARGET_MODE_DEPENDENT_ADDRESS_P xtensa_mode_dependent_address_p
>
>   #undef TARGET_RTX_COSTS
>   #define TARGET_RTX_COSTS xtensa_rtx_costs
> @@ -494,10 +499,10 @@
>   }
>
>
> -int
> -constantpool_address_p (rtx addr)
> +static bool
> +constantpool_address_p (const_rtx addr)
>   {
> -  rtx sym = addr;
> +  const_rtx sym = addr;
>
>     if (GET_CODE (addr) == CONST)
>       {
> @@ -506,21 +511,21 @@
>         /* Only handle (PLUS (SYM, OFFSET)) form.  */
>         addr = XEXP (addr, 0);
>         if (GET_CODE (addr) != PLUS)
> -       return FALSE;
> +       return false;
>
>         /* Make sure the address is word aligned.  */
>         offset = XEXP (addr, 1);
> -      if ((GET_CODE (offset) != CONST_INT)
> +      if ((!CONST_INT_P (offset))
>            || ((INTVAL (offset)&  3) != 0))
> -       return FALSE;
> +       return false;
>
>         sym = XEXP (addr, 0);
>       }
>
>     if ((GET_CODE (sym) == SYMBOL_REF)
>         &&  CONSTANT_POOL_ADDRESS_P (sym))
> -    return TRUE;
> -  return FALSE;
> +    return true;
> +  return false;
>   }
>
>
> @@ -1937,7 +1942,22 @@
>     return x;
>   }
>
> +/* Worker function for TARGET_MODE_DEPENDENT_ADDRESS_P.
>
> +   Treat constant-pool references as "mode dependent" since they can
> +   only be accessed with SImode loads.  This works around a bug in the
> +   combiner where a constant pool reference is temporarily converted
> +   to an HImode load, which is then assumed to zero-extend based on
> +   our definition of LOAD_EXTEND_OP.  This is wrong because the high
> +   bits of a 16-bit value in the constant pool are now sign-extended
> +   by default.  */
> +
> +static bool
> +xtensa_mode_dependent_address_p (const_rtx addr)
> +{
> +  return constantpool_address_p (addr);
> +}
> +
>   /* Helper for xtensa_tls_referenced_p.  */
>
>   static int
> Index: gcc/config/xtensa/xtensa.h
> ===================================================================
> --- gcc/config/xtensa/xtensa.h  (revision 168851)
> +++ gcc/config/xtensa/xtensa.h  (working copy)
> @@ -695,20 +695,6 @@
>      &&  GET_CODE (X) != LABEL_REF                                                \
>      &&  GET_CODE (X) != CONST)
>
> -/* Treat constant-pool references as "mode dependent" since they can
> -   only be accessed with SImode loads.  This works around a bug in the
> -   combiner where a constant pool reference is temporarily converted
> -   to an HImode load, which is then assumed to zero-extend based on
> -   our definition of LOAD_EXTEND_OP.  This is wrong because the high
> -   bits of a 16-bit value in the constant pool are now sign-extended
> -   by default.  */
> -
> -#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)                      \
> -  do {                                                                 \
> -    if (constantpool_address_p (ADDR))                                 \
> -      goto LABEL;                                                      \
> -  } while (0)
> -
>   /* Specify the machine mode that this machine uses
>      for the index in the tablejump instruction.  */
>   #define CASE_VECTOR_MODE (SImode)
> Index: gcc/config/xtensa/xtensa-protos.h
> ===================================================================
> --- gcc/config/xtensa/xtensa-protos.h   (revision 168851)
> +++ gcc/config/xtensa/xtensa-protos.h   (working copy)
> @@ -36,7 +36,6 @@
>   extern int xt_true_regnum (rtx);
>   extern int xtensa_valid_move (enum machine_mode, rtx *);
>   extern int smalloffset_mem_p (rtx);
> -extern int constantpool_address_p (rtx);
>   extern int constantpool_mem_p (rtx);
>   extern void xtensa_extend_reg (rtx, rtx);
>   extern void xtensa_expand_conditional_branch (rtx *, enum machine_mode);
>
>
> Anatoly.
>
diff mbox

Patch

Index: gcc/config/xtensa/xtensa.c
===================================================================
--- gcc/config/xtensa/xtensa.c  (revision 168851)
+++ gcc/config/xtensa/xtensa.c  (working copy)
@@ -126,6 +126,7 @@ 
 static struct machine_function * xtensa_init_machine_status (void);
 static rtx xtensa_legitimize_tls_address (rtx);
 static rtx xtensa_legitimize_address (rtx, rtx, enum machine_mode);
+static bool xtensa_mode_dependent_address_p (const_rtx);
 static bool xtensa_return_in_msb (const_tree);
 static void printx (FILE *, signed int);
 static void xtensa_function_epilogue (FILE *, HOST_WIDE_INT);
@@ -161,6 +162,8 @@ 
 static void xtensa_trampoline_init (rtx, tree, rtx);
 static bool xtensa_output_addr_const_extra (FILE *, rtx);
 
+static bool constantpool_address_p (const_rtx addr);
+
 static const int reg_nonleaf_alloc_order[FIRST_PSEUDO_REGISTER] =
   REG_ALLOC_ORDER;
 
@@ -201,6 +204,8 @@ 
 
 #undef TARGET_LEGITIMIZE_ADDRESS
 #define TARGET_LEGITIMIZE_ADDRESS xtensa_legitimize_address
+#undef TARGET_MODE_DEPENDENT_ADDRESS_P
+#define TARGET_MODE_DEPENDENT_ADDRESS_P xtensa_mode_dependent_address_p
 
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS xtensa_rtx_costs
@@ -494,10 +499,10 @@ 
 }
 
 
-int
-constantpool_address_p (rtx addr)
+static bool
+constantpool_address_p (const_rtx addr)
 {
-  rtx sym = addr;
+  const_rtx sym = addr;
 
   if (GET_CODE (addr) == CONST)
     {
@@ -506,21 +511,21 @@ 
       /* Only handle (PLUS (SYM, OFFSET)) form.  */
       addr = XEXP (addr, 0);
       if (GET_CODE (addr) != PLUS)
-       return FALSE;
+       return false;
 
       /* Make sure the address is word aligned.  */
       offset = XEXP (addr, 1);
-      if ((GET_CODE (offset) != CONST_INT)
+      if ((!CONST_INT_P (offset))
          || ((INTVAL (offset) & 3) != 0))
-       return FALSE;
+       return false;
 
       sym = XEXP (addr, 0);
     }
 
   if ((GET_CODE (sym) == SYMBOL_REF)
       && CONSTANT_POOL_ADDRESS_P (sym))
-    return TRUE;
-  return FALSE;
+    return true;
+  return false;
 }
 
 
@@ -1937,7 +1942,22 @@ 
   return x;
 }
 
+/* Worker function for TARGET_MODE_DEPENDENT_ADDRESS_P.
 
+   Treat constant-pool references as "mode dependent" since they can
+   only be accessed with SImode loads.  This works around a bug in the
+   combiner where a constant pool reference is temporarily converted
+   to an HImode load, which is then assumed to zero-extend based on
+   our definition of LOAD_EXTEND_OP.  This is wrong because the high
+   bits of a 16-bit value in the constant pool are now sign-extended
+   by default.  */
+
+static bool
+xtensa_mode_dependent_address_p (const_rtx addr)
+{
+  return constantpool_address_p (addr);
+}
+
 /* Helper for xtensa_tls_referenced_p.  */
 
 static int
Index: gcc/config/xtensa/xtensa.h
===================================================================
--- gcc/config/xtensa/xtensa.h  (revision 168851)
+++ gcc/config/xtensa/xtensa.h  (working copy)
@@ -695,20 +695,6 @@ 
    && GET_CODE (X) != LABEL_REF                                                \
    && GET_CODE (X) != CONST)
 
-/* Treat constant-pool references as "mode dependent" since they can
-   only be accessed with SImode loads.  This works around a bug in the
-   combiner where a constant pool reference is temporarily converted
-   to an HImode load, which is then assumed to zero-extend based on
-   our definition of LOAD_EXTEND_OP.  This is wrong because the high
-   bits of a 16-bit value in the constant pool are now sign-extended
-   by default.  */
-
-#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)                      \
-  do {                                                                 \
-    if (constantpool_address_p (ADDR))                                 \
-      goto LABEL;                                                      \
-  } while (0)
-
 /* Specify the machine mode that this machine uses
    for the index in the tablejump instruction.  */
 #define CASE_VECTOR_MODE (SImode)
Index: gcc/config/xtensa/xtensa-protos.h
===================================================================
--- gcc/config/xtensa/xtensa-protos.h   (revision 168851)
+++ gcc/config/xtensa/xtensa-protos.h   (working copy)
@@ -36,7 +36,6 @@ 
 extern int xt_true_regnum (rtx);
 extern int xtensa_valid_move (enum machine_mode, rtx *);
 extern int smalloffset_mem_p (rtx);
-extern int constantpool_address_p (rtx);
 extern int constantpool_mem_p (rtx);
 extern void xtensa_extend_reg (rtx, rtx);
 extern void xtensa_expand_conditional_branch (rtx *, enum machine_mode);