diff mbox

Move vector_type_mode to tree.c

Message ID 87k21xdz5h.fsf@linaro.org
State New
Headers show

Commit Message

Richard Sandiford Aug. 21, 2017, 9:54 a.m. UTC
...so that it's possible to use TYPE_MODE in tree.h.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Richard


2017-08-21  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	* stor-layout.h (vector_type_mode): Move to...
	* tree.h (vector_type_mode): ...here.
	* stor-layout.c (vector_type_mode): Move to...
	* tree.c (vector_type_mode): ...here.  Include rtl.h and regs.h.

Comments

Richard Biener Aug. 21, 2017, 11:02 a.m. UTC | #1
On Mon, Aug 21, 2017 at 11:54 AM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> ...so that it's possible to use TYPE_MODE in tree.h.
>
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Ok.

Richard.

> Richard
>
>
> 2017-08-21  Richard Sandiford  <richard.sandiford@linaro.org>
>
> gcc/
>         * stor-layout.h (vector_type_mode): Move to...
>         * tree.h (vector_type_mode): ...here.
>         * stor-layout.c (vector_type_mode): Move to...
>         * tree.c (vector_type_mode): ...here.  Include rtl.h and regs.h.
>
> Index: gcc/stor-layout.h
> ===================================================================
> --- gcc/stor-layout.h   2017-02-23 19:54:15.000000000 +0000
> +++ gcc/stor-layout.h   2017-08-21 10:52:43.715019857 +0100
> @@ -114,7 +114,4 @@ extern void relayout_decl (tree);
>     belongs to a function parameter.  */
>  extern tree variable_size (tree);
>
> -/* Vector types need to check target flags to determine type.  */
> -extern machine_mode vector_type_mode (const_tree);
> -
>  #endif  // GCC_STOR_LAYOUT_H
> Index: gcc/tree.h
> ===================================================================
> --- gcc/tree.h  2017-08-21 10:42:04.341552187 +0100
> +++ gcc/tree.h  2017-08-21 10:52:43.717019857 +0100
> @@ -1852,7 +1852,8 @@ #define TYPE_MODE(NODE) \
>  #define SET_TYPE_MODE(NODE, MODE) \
>    (TYPE_CHECK (NODE)->type_common.mode = (MODE))
>
> -extern machine_mode element_mode (const_tree t);
> +extern machine_mode element_mode (const_tree);
> +extern machine_mode vector_type_mode (const_tree);
>
>  /* The "canonical" type for this type node, which is used by frontends to
>     compare the type for equality with another type.  If two types are
> Index: gcc/stor-layout.c
> ===================================================================
> --- gcc/stor-layout.c   2017-08-21 10:42:05.814707501 +0100
> +++ gcc/stor-layout.c   2017-08-21 10:52:43.715019857 +0100
> @@ -2494,45 +2494,6 @@ min_align_of_type (tree type)
>      }
>    return align / BITS_PER_UNIT;
>  }
> -
> -/* Vector types need to re-check the target flags each time we report
> -   the machine mode.  We need to do this because attribute target can
> -   change the result of vector_mode_supported_p and have_regs_of_mode
> -   on a per-function basis.  Thus the TYPE_MODE of a VECTOR_TYPE can
> -   change on a per-function basis.  */
> -/* ??? Possibly a better solution is to run through all the types
> -   referenced by a function and re-compute the TYPE_MODE once, rather
> -   than make the TYPE_MODE macro call a function.  */
> -
> -machine_mode
> -vector_type_mode (const_tree t)
> -{
> -  machine_mode mode;
> -
> -  gcc_assert (TREE_CODE (t) == VECTOR_TYPE);
> -
> -  mode = t->type_common.mode;
> -  if (VECTOR_MODE_P (mode)
> -      && (!targetm.vector_mode_supported_p (mode)
> -         || !have_regs_of_mode[mode]))
> -    {
> -      machine_mode innermode = TREE_TYPE (t)->type_common.mode;
> -
> -      /* For integers, try mapping it to a same-sized scalar mode.  */
> -      if (GET_MODE_CLASS (innermode) == MODE_INT)
> -       {
> -         mode = mode_for_size (TYPE_VECTOR_SUBPARTS (t)
> -                               * GET_MODE_BITSIZE (innermode), MODE_INT, 0);
> -
> -         if (mode != VOIDmode && have_regs_of_mode[mode])
> -           return mode;
> -       }
> -
> -      return BLKmode;
> -    }
> -
> -  return mode;
> -}
>
>  /* Create and return a type for signed integers of PRECISION bits.  */
>
> Index: gcc/tree.c
> ===================================================================
> --- gcc/tree.c  2017-08-21 10:42:04.340629158 +0100
> +++ gcc/tree.c  2017-08-21 10:52:43.717019857 +0100
> @@ -64,6 +64,8 @@ Software Foundation; either version 3, o
>  #include "selftest.h"
>  #include "stringpool.h"
>  #include "attribs.h"
> +#include "rtl.h"
> +#include "regs.h"
>
>  /* Tree code classes.  */
>
> @@ -12598,9 +12600,47 @@ element_mode (const_tree t)
>      t = TREE_TYPE (t);
>    return TYPE_MODE (t);
>  }
> -
>
> -/* Veirfy that basic properties of T match TV and thus T can be a variant of
> +/* Vector types need to re-check the target flags each time we report
> +   the machine mode.  We need to do this because attribute target can
> +   change the result of vector_mode_supported_p and have_regs_of_mode
> +   on a per-function basis.  Thus the TYPE_MODE of a VECTOR_TYPE can
> +   change on a per-function basis.  */
> +/* ??? Possibly a better solution is to run through all the types
> +   referenced by a function and re-compute the TYPE_MODE once, rather
> +   than make the TYPE_MODE macro call a function.  */
> +
> +machine_mode
> +vector_type_mode (const_tree t)
> +{
> +  machine_mode mode;
> +
> +  gcc_assert (TREE_CODE (t) == VECTOR_TYPE);
> +
> +  mode = t->type_common.mode;
> +  if (VECTOR_MODE_P (mode)
> +      && (!targetm.vector_mode_supported_p (mode)
> +         || !have_regs_of_mode[mode]))
> +    {
> +      machine_mode innermode = TREE_TYPE (t)->type_common.mode;
> +
> +      /* For integers, try mapping it to a same-sized scalar mode.  */
> +      if (GET_MODE_CLASS (innermode) == MODE_INT)
> +       {
> +         mode = mode_for_size (TYPE_VECTOR_SUBPARTS (t)
> +                               * GET_MODE_BITSIZE (innermode), MODE_INT, 0);
> +
> +         if (mode != VOIDmode && have_regs_of_mode[mode])
> +           return mode;
> +       }
> +
> +      return BLKmode;
> +    }
> +
> +  return mode;
> +}
> +
> +/* Verify that basic properties of T match TV and thus T can be a variant of
>     TV.  TV should be the more specified variant (i.e. the main variant).  */
>
>  static bool
diff mbox

Patch

Index: gcc/stor-layout.h
===================================================================
--- gcc/stor-layout.h	2017-02-23 19:54:15.000000000 +0000
+++ gcc/stor-layout.h	2017-08-21 10:52:43.715019857 +0100
@@ -114,7 +114,4 @@  extern void relayout_decl (tree);
    belongs to a function parameter.  */
 extern tree variable_size (tree);
 
-/* Vector types need to check target flags to determine type.  */
-extern machine_mode vector_type_mode (const_tree);
-
 #endif  // GCC_STOR_LAYOUT_H
Index: gcc/tree.h
===================================================================
--- gcc/tree.h	2017-08-21 10:42:04.341552187 +0100
+++ gcc/tree.h	2017-08-21 10:52:43.717019857 +0100
@@ -1852,7 +1852,8 @@  #define TYPE_MODE(NODE) \
 #define SET_TYPE_MODE(NODE, MODE) \
   (TYPE_CHECK (NODE)->type_common.mode = (MODE))
 
-extern machine_mode element_mode (const_tree t);
+extern machine_mode element_mode (const_tree);
+extern machine_mode vector_type_mode (const_tree);
 
 /* The "canonical" type for this type node, which is used by frontends to
    compare the type for equality with another type.  If two types are
Index: gcc/stor-layout.c
===================================================================
--- gcc/stor-layout.c	2017-08-21 10:42:05.814707501 +0100
+++ gcc/stor-layout.c	2017-08-21 10:52:43.715019857 +0100
@@ -2494,45 +2494,6 @@  min_align_of_type (tree type)
     }
   return align / BITS_PER_UNIT;
 }
-
-/* Vector types need to re-check the target flags each time we report
-   the machine mode.  We need to do this because attribute target can
-   change the result of vector_mode_supported_p and have_regs_of_mode
-   on a per-function basis.  Thus the TYPE_MODE of a VECTOR_TYPE can
-   change on a per-function basis.  */
-/* ??? Possibly a better solution is to run through all the types
-   referenced by a function and re-compute the TYPE_MODE once, rather
-   than make the TYPE_MODE macro call a function.  */
-
-machine_mode
-vector_type_mode (const_tree t)
-{
-  machine_mode mode;
-
-  gcc_assert (TREE_CODE (t) == VECTOR_TYPE);
-
-  mode = t->type_common.mode;
-  if (VECTOR_MODE_P (mode)
-      && (!targetm.vector_mode_supported_p (mode)
-	  || !have_regs_of_mode[mode]))
-    {
-      machine_mode innermode = TREE_TYPE (t)->type_common.mode;
-
-      /* For integers, try mapping it to a same-sized scalar mode.  */
-      if (GET_MODE_CLASS (innermode) == MODE_INT)
-	{
-	  mode = mode_for_size (TYPE_VECTOR_SUBPARTS (t)
-				* GET_MODE_BITSIZE (innermode), MODE_INT, 0);
-
-	  if (mode != VOIDmode && have_regs_of_mode[mode])
-	    return mode;
-	}
-
-      return BLKmode;
-    }
-
-  return mode;
-}
 
 /* Create and return a type for signed integers of PRECISION bits.  */
 
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	2017-08-21 10:42:04.340629158 +0100
+++ gcc/tree.c	2017-08-21 10:52:43.717019857 +0100
@@ -64,6 +64,8 @@  Software Foundation; either version 3, o
 #include "selftest.h"
 #include "stringpool.h"
 #include "attribs.h"
+#include "rtl.h"
+#include "regs.h"
 
 /* Tree code classes.  */
 
@@ -12598,9 +12600,47 @@  element_mode (const_tree t)
     t = TREE_TYPE (t);
   return TYPE_MODE (t);
 }
- 
 
-/* Veirfy that basic properties of T match TV and thus T can be a variant of
+/* Vector types need to re-check the target flags each time we report
+   the machine mode.  We need to do this because attribute target can
+   change the result of vector_mode_supported_p and have_regs_of_mode
+   on a per-function basis.  Thus the TYPE_MODE of a VECTOR_TYPE can
+   change on a per-function basis.  */
+/* ??? Possibly a better solution is to run through all the types
+   referenced by a function and re-compute the TYPE_MODE once, rather
+   than make the TYPE_MODE macro call a function.  */
+
+machine_mode
+vector_type_mode (const_tree t)
+{
+  machine_mode mode;
+
+  gcc_assert (TREE_CODE (t) == VECTOR_TYPE);
+
+  mode = t->type_common.mode;
+  if (VECTOR_MODE_P (mode)
+      && (!targetm.vector_mode_supported_p (mode)
+	  || !have_regs_of_mode[mode]))
+    {
+      machine_mode innermode = TREE_TYPE (t)->type_common.mode;
+
+      /* For integers, try mapping it to a same-sized scalar mode.  */
+      if (GET_MODE_CLASS (innermode) == MODE_INT)
+	{
+	  mode = mode_for_size (TYPE_VECTOR_SUBPARTS (t)
+				* GET_MODE_BITSIZE (innermode), MODE_INT, 0);
+
+	  if (mode != VOIDmode && have_regs_of_mode[mode])
+	    return mode;
+	}
+
+      return BLKmode;
+    }
+
+  return mode;
+}
+
+/* Verify that basic properties of T match TV and thus T can be a variant of
    TV.  TV should be the more specified variant (i.e. the main variant).  */
 
 static bool