Patchwork [BFIN] Hookize PREFERRED_RELOAD_CLASS

login
register
mail settings
Submitter Anatoly Sokolov
Date Jan. 5, 2012, 6:51 p.m.
Message ID <4F05F12F.6000007@post.ru>
Download mbox | patch
Permalink /patch/134533/
State New
Headers show

Comments

Anatoly Sokolov - Jan. 5, 2012, 6:51 p.m.
Hi.

   This patch removes obsolete PREFERRED_RELOAD_CLASS macro from the BFIN back 
end in the GCC and introduces equivalent TARGET_PREFERRED_RELOAD_CLASS target 
hook.

   Compiled. Untested.

   OK to install?

	* config/bfin/bfin.h (PREFERRED_RELOAD_CLASS): Remove.
	* config/bfin/bfin.c (TARGET_PREFERRED_RELOAD_CLASS): Define.
	(bfin_preferred_reload_class): New function.
Jie Zhang - Jan. 6, 2012, 4:28 a.m.
Hi Anatoly,

The patch looks OK.

But I cannot apply your patch by saving your email as a patch file. If
you take a look at this:

http://gcc.gnu.org/cgi-bin/get-raw-msg?listname=gcc-patches&date=2012-01&msgid=4F05F12F.6000007%40post.ru

you will find that there is a extra white space before each context
line. But these extra white spaces do not show up in

http://gcc.gnu.org/ml/gcc-patches/2012-01/msg00262.html

while the starting white space of the last line of the patch is missing.

Regards,
Jie


On Thu, Jan 5, 2012 at 1:51 PM, Anatoly Sokolov <aesok@post.ru> wrote:
>  Hi.
>
>  This patch removes obsolete PREFERRED_RELOAD_CLASS macro from the BFIN back
> end in the GCC and introduces equivalent TARGET_PREFERRED_RELOAD_CLASS
> target hook.
>
>  Compiled. Untested.
>
>  OK to install?
>
>        * config/bfin/bfin.h (PREFERRED_RELOAD_CLASS): Remove.
>        * config/bfin/bfin.c (TARGET_PREFERRED_RELOAD_CLASS): Define.
>        (bfin_preferred_reload_class): New function.
>
>
> Index: gcc/config/bfin/bfin.c
> ===================================================================
> --- gcc/config/bfin/bfin.c      (revision 182912)
> +++ gcc/config/bfin/bfin.c      (working copy)
> @@ -2648,6 +2648,19 @@ split_load_immediate (rtx operands[])
>   return 0;
>  }
>
> +/* Worker function for TARGET_PREFERRED_RELOAD_CLASS.  */
> +
> +static reg_class_t
> +bfin_preferred_reload_class (rtx x, reg_class_t rclass)
> +{
> +  if (GET_CODE (x) == POST_INC
> +      || GET_CODE (x) == POST_DEC
> +      || GET_CODE (x) == PRE_DEC)
> +    return PREGS;
> +
> +  return rclass;
> +}
> +
>  /* Return true if the legitimate memory address for a memory operand of
> mode
>    MODE.  Return false if not.  */
>
> @@ -5771,6 +5784,9 @@ bfin_conditional_register_usage (void)
>  #undef TARGET_RETURN_IN_MEMORY
>  #define TARGET_RETURN_IN_MEMORY bfin_return_in_memory
>
> +#undef  TARGET_PREFERRED_RELOAD_CLASS
> +#define TARGET_PREFERRED_RELOAD_CLASS bfin_preferred_reload_class
> +
>  #undef TARGET_LEGITIMATE_ADDRESS_P
>  #define TARGET_LEGITIMATE_ADDRESS_P    bfin_legitimate_address_p
>
> Index: gcc/config/bfin/bfin.h
> ===================================================================
> --- gcc/config/bfin/bfin.h      (revision 182912)
> +++ gcc/config/bfin/bfin.h      (working copy)
> @@ -707,16 +707,6 @@ enum reg_class
>       && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD       \
>       && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD))
>
> -/* `PREFERRED_RELOAD_CLASS (X, CLASS)'
> -   A C expression that places additional restrictions on the register
> -   class to use when it is necessary to copy value X into a register
> -   in class CLASS.  The value is a register class; perhaps CLASS, or
> -   perhaps another, smaller class.  */
> -#define PREFERRED_RELOAD_CLASS(X, CLASS)               \
> -  (GET_CODE (X) == POST_INC                            \
> -   || GET_CODE (X) == POST_DEC                         \
> -   || GET_CODE (X) == PRE_DEC ? PREGS : (CLASS))
> -
>  /* Function Calling Conventions. */
>
>  /* The type of the current function; normal functions are of type
>
>
> --
> Anatoly.
Anatoly Sokolov - Jan. 6, 2012, 5:07 p.m.
Hi, Jie.

On Jan 6, 2012, Jie Zhang <jzhang918@gmail.com> wrote:

> Hi Anatoly,

> The patch looks OK.

> But I cannot apply your patch by saving your email as a patch file. If
> you take a look at this:


I attach the patch.

Anatoly.
Jie Zhang - Jan. 7, 2012, 5:20 a.m.
On 01/06/2012 12:07 PM, Anatoly Sokolov wrote:
> Hi, Jie.
>
> On Jan 6, 2012, Jie Zhang<jzhang918@gmail.com>  wrote:
>
>> Hi Anatoly,
>
>> The patch looks OK.
>
>> But I cannot apply your patch by saving your email as a patch file. If
>> you take a look at this:
>
>
> I attach the patch.
>
I can apply the attached patch. OK. Thank you.


Jie

Patch

Index: gcc/config/bfin/bfin.c
===================================================================
--- gcc/config/bfin/bfin.c	(revision 182912)
+++ gcc/config/bfin/bfin.c	(working copy)
@@ -2648,6 +2648,19 @@  split_load_immediate (rtx operands[])
    return 0;
  }
  
+/* Worker function for TARGET_PREFERRED_RELOAD_CLASS.  */
+
+static reg_class_t
+bfin_preferred_reload_class (rtx x, reg_class_t rclass)
+{
+  if (GET_CODE (x) == POST_INC
+      || GET_CODE (x) == POST_DEC
+      || GET_CODE (x) == PRE_DEC)
+    return PREGS;
+
+  return rclass;
+}
+
  /* Return true if the legitimate memory address for a memory operand of mode
     MODE.  Return false if not.  */

@@ -5771,6 +5784,9 @@  bfin_conditional_register_usage (void)
  #undef TARGET_RETURN_IN_MEMORY
  #define TARGET_RETURN_IN_MEMORY bfin_return_in_memory

+#undef  TARGET_PREFERRED_RELOAD_CLASS
+#define TARGET_PREFERRED_RELOAD_CLASS bfin_preferred_reload_class
+
  #undef TARGET_LEGITIMATE_ADDRESS_P
  #define TARGET_LEGITIMATE_ADDRESS_P	bfin_legitimate_address_p

Index: gcc/config/bfin/bfin.h
===================================================================
--- gcc/config/bfin/bfin.h	(revision 182912)
+++ gcc/config/bfin/bfin.h	(working copy)
@@ -707,16 +707,6 @@  enum reg_class
        && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD	\
        && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD))

-/* `PREFERRED_RELOAD_CLASS (X, CLASS)'
-   A C expression that places additional restrictions on the register
-   class to use when it is necessary to copy value X into a register
-   in class CLASS.  The value is a register class; perhaps CLASS, or
-   perhaps another, smaller class.  */
-#define PREFERRED_RELOAD_CLASS(X, CLASS)		\
-  (GET_CODE (X) == POST_INC				\
-   || GET_CODE (X) == POST_DEC				\
-   || GET_CODE (X) == PRE_DEC ? PREGS : (CLASS))
-
  /* Function Calling Conventions. */

  /* The type of the current function; normal functions are of type