From e386a52f70c47499fff14a338fe17df691e886e2 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 30 Aug 2017 11:09:10 +0000 Subject: [7/77] Add scalar_float_mode This patch adds a scalar_float_mode class, which wraps a mode enum that is known to satisfy SCALAR_FLOAT_MODE_P. Things like "SFmode" now give a scalar_float_mode object instead of a machine_mode. This in turn needs a change to the real.h format_helper, so that it can accept both machine_modes and scalar_float_modes. 2017-08-30 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (scalar_float_mode): New type. * machmode.h (mode_traits::from_int): Use machine_mode if USE_ENUM_MODES is defined. (is_a): New function. (as_a): Likewise. (dyn_cast): Likewise. (scalar_float_mode): New class. (scalar_float_mode::includes_p): New function. (is_float_mode): Likewise. * gdbhooks.py (MachineModePrinter): New class. (build_pretty_printer): Use it for scalar_float_mode. * real.h (FLOAT_MODE_FORMAT): Use as_a . (format_helper::format_helper): Turn into a template. * genmodes.c (get_mode_class): New function. (emit_insn_modes_h): Give modes the class returned by get_mode_class, or machine_mode if none. * config/aarch64/aarch64.c (aarch64_simd_valid_immediate): Use as_a . * dwarf2out.c (mem_loc_descriptor): Likewise. (insert_float): Likewise. (add_const_value_attribute): Likewise. * simplify-rtx.c (simplify_immed_subreg): Likewise. * optabs.c (expand_absneg_bit): Take a scalar_float_mode. (expand_unop): Update accordingly. (expand_abs_nojump): Likewise. (expand_copysign_absneg): Take a scalar_float_mode. (expand_copysign_bit): Likewise. (expand_copysign): Update accordingly. gcc/ada/ * gcc-interface/utils.c (gnat_type_for_mode): Use is_a instead of SCALAR_FLOAT_MODE_P. gcc/go/ * go-lang.c (go_langhook_type_for_mode): Use is_float_mode. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r251458 --- gcc/go/go-lang.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc/go/go-lang.c') diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c index 09e4fea..614d890 100644 --- a/gcc/go/go-lang.c +++ b/gcc/go/go-lang.c @@ -382,12 +382,13 @@ go_langhook_type_for_mode (machine_mode mode, int unsignedp) return NULL_TREE; } + scalar_float_mode fmode; enum mode_class mc = GET_MODE_CLASS (mode); if (mc == MODE_INT) return go_langhook_type_for_size (GET_MODE_BITSIZE (mode), unsignedp); - else if (mc == MODE_FLOAT) + else if (is_float_mode (mode, &fmode)) { - switch (GET_MODE_BITSIZE (mode)) + switch (GET_MODE_BITSIZE (fmode)) { case 32: return float_type_node; @@ -396,7 +397,7 @@ go_langhook_type_for_mode (machine_mode mode, int unsignedp) default: // We have to check for long double in order to support // i386 excess precision. - if (mode == TYPE_MODE(long_double_type_node)) + if (fmode == TYPE_MODE(long_double_type_node)) return long_double_type_node; } } -- cgit v1.1