aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/misc.c
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/ada/gcc-interface/misc.c
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/ada/gcc-interface/misc.c')
-rw-r--r--gcc/ada/gcc-interface/misc.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index eaacabd..081a63a 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -1311,11 +1311,14 @@ enumerate_modes (void (*f) (const char *, int, int, int, int, int, int, int))
int
fp_prec_to_size (int prec)
{
- machine_mode mode;
+ opt_scalar_float_mode opt_mode;
- FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT)
- if (GET_MODE_PRECISION (mode) == prec)
- return GET_MODE_BITSIZE (mode);
+ FOR_EACH_MODE_IN_CLASS (opt_mode, MODE_FLOAT)
+ {
+ scalar_float_mode mode = opt_mode.require ();
+ if (GET_MODE_PRECISION (mode) == prec)
+ return GET_MODE_BITSIZE (mode);
+ }
gcc_unreachable ();
}
@@ -1325,11 +1328,14 @@ fp_prec_to_size (int prec)
int
fp_size_to_prec (int size)
{
- machine_mode mode;
+ opt_scalar_float_mode opt_mode;
- FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT)
- if (GET_MODE_BITSIZE (mode) == size)
- return GET_MODE_PRECISION (mode);
+ FOR_EACH_MODE_IN_CLASS (opt_mode, MODE_FLOAT)
+ {
+ scalar_mode mode = opt_mode.require ();
+ if (GET_MODE_BITSIZE (mode) == size)
+ return GET_MODE_PRECISION (mode);
+ }
gcc_unreachable ();
}