diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-09-05 19:57:28 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-09-05 19:57:28 +0000 |
commit | ddc203a7b15306287792a3eed6abfe306e3d26ad (patch) | |
tree | 70d42d6bad62e909cc47a2cbfc83768e6d71f952 /gcc/machmode.h | |
parent | 61b2290a5c248efd43dd45b1b256e7f792f21f02 (diff) | |
download | gcc-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/machmode.h')
-rw-r--r-- | gcc/machmode.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/machmode.h b/gcc/machmode.h index 956e2c0..7dd71e9 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -706,6 +706,21 @@ extern machine_mode bitwise_mode_for_mode (machine_mode); extern machine_mode mode_for_vector (scalar_mode, unsigned); +extern opt_machine_mode mode_for_int_vector (unsigned int, unsigned int); + +/* Return the integer vector equivalent of MODE, if one exists. In other + words, return the mode for an integer vector that has the same number + of bits as MODE and the same number of elements as MODE, with the + latter being 1 if MODE is scalar. The returned mode can be either + an integer mode or a vector mode. */ + +inline opt_machine_mode +mode_for_int_vector (machine_mode mode) +{ + return mode_for_int_vector (GET_MODE_UNIT_BITSIZE (mode), + GET_MODE_NUNITS (mode)); +} + /* A class for iterating through possible bitfield modes. */ class bit_field_mode_iterator { |