aboutsummaryrefslogtreecommitdiff
path: root/gcc/machmode.h
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-08-30 11:09:48 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-08-30 11:09:48 +0000
commit5c20c4af29da29d2bb74b1fdf3c116f564431878 (patch)
tree7e03f2635a9fe715b2717872ffe1afc0cc1cfde8 /gcc/machmode.h
parent857c7b46875bdcf9d889543baad54977034d57ef (diff)
downloadgcc-5c20c4af29da29d2bb74b1fdf3c116f564431878.zip
gcc-5c20c4af29da29d2bb74b1fdf3c116f564431878.tar.gz
gcc-5c20c4af29da29d2bb74b1fdf3c116f564431878.tar.bz2
[12/77] Use opt_scalar_float_mode when iterating over float modes
This means that we know when accessing the modes that the size is a compile-time constant, even for SVE. It also enables stricter type safety in later patches. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * machmode.h (mode_iterator::start): Provide overload for opt_modes. (mode_iterator::iterate_p): Likewise. (mode_iterator::get_wider): Likewise. * expr.c (init_expr_target): Use opt_scalar_float_mode. gcc/ada/ * gcc-interface/misc.c (fp_prec_to_size): Use opt_scalar_float_mode. (fp_size_to_prec): Likewise. gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins): Use opt_scalar_float_mode. gcc/fortran/ * trans-types.c (gfc_init_kinds): Use opt_scalar_float_mode and FOR_EACH_MODE_IN_CLASS. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251464
Diffstat (limited to 'gcc/machmode.h')
-rw-r--r--gcc/machmode.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/machmode.h b/gcc/machmode.h
index aa931f5..2603d83 100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -651,6 +651,16 @@ namespace mode_iterator
{
/* Start mode iterator *ITER at the first mode in class MCLASS, if any. */
+ template<typename T>
+ inline void
+ start (opt_mode<T> *iter, enum mode_class mclass)
+ {
+ if (GET_CLASS_NARROWEST_MODE (mclass) == E_VOIDmode)
+ *iter = opt_mode<T> ();
+ else
+ *iter = as_a<T> (GET_CLASS_NARROWEST_MODE (mclass));
+ }
+
inline void
start (machine_mode *iter, enum mode_class mclass)
{
@@ -659,6 +669,13 @@ namespace mode_iterator
/* Return true if mode iterator *ITER has not reached the end. */
+ template<typename T>
+ inline bool
+ iterate_p (opt_mode<T> *iter)
+ {
+ return iter->exists ();
+ }
+
inline bool
iterate_p (machine_mode *iter)
{
@@ -668,6 +685,13 @@ namespace mode_iterator
/* Set mode iterator *ITER to the next widest mode in the same class,
if any. */
+ template<typename T>
+ inline void
+ get_wider (opt_mode<T> *iter)
+ {
+ *iter = GET_MODE_WIDER_MODE (iter->require ());
+ }
+
inline void
get_wider (machine_mode *iter)
{