diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-08-30 11:09:41 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-08-30 11:09:41 +0000 |
commit | 857c7b46875bdcf9d889543baad54977034d57ef (patch) | |
tree | 60a693fba5c631712da730e6ce07a8deda2af759 /gcc/stor-layout.c | |
parent | d16c828e7aa2a704d887b071864823fc1e39670f (diff) | |
download | gcc-857c7b46875bdcf9d889543baad54977034d57ef.zip gcc-857c7b46875bdcf9d889543baad54977034d57ef.tar.gz gcc-857c7b46875bdcf9d889543baad54977034d57ef.tar.bz2 |
[11/77] Add a float_mode_for_size helper function
This provides a type-safe way to ask for a float mode and get it as a
scalar_float_mode.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* coretypes.h (opt_scalar_float_mode): New typedef.
* machmode.h (float_mode_for_size): New function.
* emit-rtl.c (double_mode): Delete.
(init_emit_once): Use float_mode_for_size.
* stor-layout.c (layout_type): Likewise.
* gdbhooks.py (build_pretty_printer): Handle opt_scalar_float_mode.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r251463
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index f69fad8..433fd99 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2205,14 +2205,17 @@ layout_type (tree type) break; case REAL_TYPE: - /* Allow the caller to choose the type mode, which is how decimal - floats are distinguished from binary ones. */ - if (TYPE_MODE (type) == VOIDmode) - SET_TYPE_MODE (type, - mode_for_size (TYPE_PRECISION (type), MODE_FLOAT, 0)); - TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type))); - TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type))); - break; + { + /* Allow the caller to choose the type mode, which is how decimal + floats are distinguished from binary ones. */ + if (TYPE_MODE (type) == VOIDmode) + SET_TYPE_MODE + (type, float_mode_for_size (TYPE_PRECISION (type)).require ()); + scalar_float_mode mode = as_a <scalar_float_mode> (TYPE_MODE (type)); + TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (mode)); + TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (mode)); + break; + } case FIXED_POINT_TYPE: /* TYPE_MODE (type) has been set already. */ |