aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-08-21 11:14:56 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-08-21 11:14:56 +0000
commitc34960677437197ee2859b243cf185c7f873c83b (patch)
treefb7a8b55c4a33c93113444dc8e97c38e7d662cc8 /gcc/tree.c
parent1ea85365b430b5ade1d0b824e5406c006e6ffdb7 (diff)
downloadgcc-c34960677437197ee2859b243cf185c7f873c83b.zip
gcc-c34960677437197ee2859b243cf185c7f873c83b.tar.gz
gcc-c34960677437197ee2859b243cf185c7f873c83b.tar.bz2
Move vector_type_mode to tree.c
...so that it's possible to use TYPE_MODE in tree.h. 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. From-SVN: r251221
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 07523a6..4f56892 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -64,6 +64,8 @@ along with GCC; see the file COPYING3. If not see
#include "selftest.h"
#include "stringpool.h"
#include "attribs.h"
+#include "rtl.h"
+#include "regs.h"
/* Tree code classes. */
@@ -12610,9 +12612,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