aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-09-05 19:57:28 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-09-05 19:57:28 +0000
commitddc203a7b15306287792a3eed6abfe306e3d26ad (patch)
tree70d42d6bad62e909cc47a2cbfc83768e6d71f952 /gcc/stor-layout.c
parent61b2290a5c248efd43dd45b1b256e7f792f21f02 (diff)
downloadgcc-ddc203a7b15306287792a3eed6abfe306e3d26ad.zip
gcc-ddc203a7b15306287792a3eed6abfe306e3d26ad.tar.gz
gcc-ddc203a7b15306287792a3eed6abfe306e3d26ad.tar.bz2
Add mode_for_int_vector helper functions
There are at least a few places that want to create an integer vector with a specified element size and element count, or to create the integer equivalent of an existing mode. This patch adds helpers for doing that. The require ()s are all used in functions that go on to emit instructions that use the result as a vector mode. 2017-09-05 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * machmode.h (mode_for_int_vector): New function. * stor-layout.c (mode_for_int_vector): Likewise. * config/aarch64/aarch64.c (aarch64_emit_approx_sqrt): Use it. * config/powerpcspe/powerpcspe.c (rs6000_do_expand_vec_perm): Likewise. * config/rs6000/rs6000.c (rs6000_do_expand_vec_perm): Likewise. * config/s390/s390.c (s390_expand_vec_compare_cc): Likewise. (s390_expand_vcond): Likewise. From-SVN: r251729
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index f9a28e7..6bb7b24 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -517,6 +517,23 @@ mode_for_vector (scalar_mode innermode, unsigned nunits)
return mode;
}
+/* Return the mode for a vector that has NUNITS integer elements of
+ INT_BITS bits each, if such a mode exists. The mode can be either
+ an integer mode or a vector mode. */
+
+opt_machine_mode
+mode_for_int_vector (unsigned int int_bits, unsigned int nunits)
+{
+ scalar_int_mode int_mode;
+ if (int_mode_for_size (int_bits, 0).exists (&int_mode))
+ {
+ machine_mode vec_mode = mode_for_vector (int_mode, nunits);
+ if (vec_mode != BLKmode)
+ return vec_mode;
+ }
+ return opt_machine_mode ();
+}
+
/* Return the alignment of MODE. This will be bounded by 1 and
BIGGEST_ALIGNMENT. */