Patchwork [M32C] Hookize CLASS_MAX_NREGS

login
register
mail settings
Submitter Anatoly Sokolov
Date Aug. 22, 2011, 7:12 p.m.
Message ID <9810488346.20110822231215@post.ru>
Download mbox | patch
Permalink /patch/110974/
State New
Headers show

Comments

Anatoly Sokolov - Aug. 22, 2011, 7:12 p.m.
Hi.

  This patch removes obsolete CLASS_MAX_NREGS macro from M32C back end in the 
GCC and introduces equivalent TARGET_CLASS_MAX_NREGS target hooks.

  Regression tested on m32c-unknown-elf.

  OK to install?

        * config/m32c/m32c.h (CLASS_MAX_NREGS): Remove macro.
        * config/m32c/m32c-protos.h (m32c_class_max_nregs): Remove.
        * config/m32c/m32c.c (m32c_class_max_nregs): Make static. Change
        regclass argument type to reg_class_t. Change 'max' and 'v' vars
        and return types to unsigned char. Use reg_class_contents instead
        of class_contents.
        (TARGET_CLASS_MAX_NREGS): Define.




Anatoly.
DJ Delorie - Aug. 22, 2011, 7:19 p.m.
>   OK to install?
> 
>         * config/m32c/m32c.h (CLASS_MAX_NREGS): Remove macro.
>         * config/m32c/m32c-protos.h (m32c_class_max_nregs): Remove.
>         * config/m32c/m32c.c (m32c_class_max_nregs): Make static. Change
>         regclass argument type to reg_class_t. Change 'max' and 'v' vars
>         and return types to unsigned char. Use reg_class_contents instead
>         of class_contents.
>         (TARGET_CLASS_MAX_NREGS): Define.

Ok.

Patch

Index: gcc/config/m32c/m32c.c
===================================================================
--- gcc/config/m32c/m32c.c      (revision 177968)
+++ gcc/config/m32c/m32c.c      (working copy)
@@ -859,18 +859,23 @@ 
   return (reg_class_size[(int) regclass] == 1);
 }
 
-/* Implements CLASS_MAX_NREGS.  We calculate this according to its
+/* Implements TARGET_CLASS_MAX_NREGS.  We calculate this according to its
    documented meaning, to avoid potential inconsistencies with actual
    class definitions.  */
-int
-m32c_class_max_nregs (int regclass, enum machine_mode mode)
+
+#undef TARGET_CLASS_MAX_NREGS
+#define TARGET_CLASS_MAX_NREGS m32c_class_max_nregs
+
+static unsigned char
+m32c_class_max_nregs (reg_class_t regclass, enum machine_mode mode)
 {
-  int rn, max = 0;
+  int rn;
+  unsigned char max = 0;
 
   for (rn = 0; rn < FIRST_PSEUDO_REGISTER; rn++)
-    if (class_contents[regclass][0] & (1 << rn))
+    if (TEST_HARD_REG_BIT (reg_class_contents[(int) regclass], rn))
       {
-       int n = m32c_hard_regno_nregs (rn, mode);
+       unsigned char n = m32c_hard_regno_nregs (rn, mode);
        if (max < n)
          max = n;
       }
Index: gcc/config/m32c/m32c.h
===================================================================
--- gcc/config/m32c/m32c.h      (revision 177968)
+++ gcc/config/m32c/m32c.h      (working copy)
@@ -425,8 +425,6 @@ 
 
 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
 
-#define CLASS_MAX_NREGS(C,M) m32c_class_max_nregs (C, M)
-
 #define CANNOT_CHANGE_MODE_CLASS(F,T,C) m32c_cannot_change_mode_class(F,T,C)
 
 #define CONST_OK_FOR_CONSTRAINT_P(VALUE,C,STR) \
Index: gcc/config/m32c/m32c-protos.h
===================================================================
--- gcc/config/m32c/m32c-protos.h       (revision 177968)
+++ gcc/config/m32c/m32c-protos.h       (working copy)
@@ -44,7 +44,6 @@ 
 #ifdef RTX_CODE
 
 int  m32c_cannot_change_mode_class (enum machine_mode, enum machine_mode, int);
-int  m32c_class_max_nregs (int, enum machine_mode);
 rtx  m32c_eh_return_stackadj_rtx (void);
 void m32c_emit_eh_epilogue (rtx);
 int  m32c_expand_cmpstr (rtx *);