aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-08-30 11:09:56 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-08-30 11:09:56 +0000
commit1ce87609c91e51d7eee8284c5fe000c7d5b240db (patch)
tree546db64fb195401be1446efc42e41df63d77178e
parent5c20c4af29da29d2bb74b1fdf3c116f564431878 (diff)
downloadgcc-1ce87609c91e51d7eee8284c5fe000c7d5b240db.zip
gcc-1ce87609c91e51d7eee8284c5fe000c7d5b240db.tar.gz
gcc-1ce87609c91e51d7eee8284c5fe000c7d5b240db.tar.bz2
[13/77] Make floatn_mode return an opt_scalar_float_mode
As per subject. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * target.def (default_floatn_mode): Return an opt_scalar_float_mode. * doc/tm.texi: Regenerate. * config/arm/arm.c (arm_floatn_mode): Return an opt_scalar_float_mode. * config/powerpcspe/powerpcspe.c (rs6000_floatn_mode): Likewise. * config/rs6000/rs6000.c (rs6000_floatn_mode): Likewise. * targhooks.h (default_floatn_mode): Likewise. * targhooks.c (default_floatn_mode): Likewise. * tree.c (build_common_tree_nodes): Update accordingly. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251465
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/config/arm/arm.c10
-rw-r--r--gcc/config/powerpcspe/powerpcspe.c10
-rw-r--r--gcc/config/rs6000/rs6000.c10
-rw-r--r--gcc/doc/tm.texi16
-rw-r--r--gcc/target.def16
-rw-r--r--gcc/targhooks.c34
-rw-r--r--gcc/targhooks.h2
-rw-r--r--gcc/tree.c4
9 files changed, 67 insertions, 48 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f5fb5fc..a261c18 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -2,6 +2,19 @@
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
+ * target.def (default_floatn_mode): Return an opt_scalar_float_mode.
+ * doc/tm.texi: Regenerate.
+ * config/arm/arm.c (arm_floatn_mode): Return an opt_scalar_float_mode.
+ * config/powerpcspe/powerpcspe.c (rs6000_floatn_mode): Likewise.
+ * config/rs6000/rs6000.c (rs6000_floatn_mode): Likewise.
+ * targhooks.h (default_floatn_mode): Likewise.
+ * targhooks.c (default_floatn_mode): Likewise.
+ * tree.c (build_common_tree_nodes): Update accordingly.
+
+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
* machmode.h (mode_iterator::start): Provide overload for opt_modes.
(mode_iterator::iterate_p): Likewise.
(mode_iterator::get_wider): Likewise.
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 3b16c7a..982ea7e 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -312,7 +312,7 @@ static bool arm_asm_elf_flags_numeric (unsigned int flags, unsigned int *num);
static unsigned int arm_elf_section_type_flags (tree decl, const char *name,
int reloc);
static void arm_expand_divmod_libfunc (rtx, machine_mode, rtx, rtx, rtx *, rtx *);
-static machine_mode arm_floatn_mode (int, bool);
+static opt_scalar_float_mode arm_floatn_mode (int, bool);
/* Table of machine attributes. */
static const struct attribute_spec arm_attribute_table[] =
@@ -23656,11 +23656,15 @@ arm_excess_precision (enum excess_precision_type type)
/* Implement TARGET_FLOATN_MODE. Make very sure that we don't provide
_Float16 if we are using anything other than ieee format for 16-bit
floating point. Otherwise, punt to the default implementation. */
-static machine_mode
+static opt_scalar_float_mode
arm_floatn_mode (int n, bool extended)
{
if (!extended && n == 16)
- return arm_fp16_format == ARM_FP16_FORMAT_IEEE ? HFmode : VOIDmode;
+ {
+ if (arm_fp16_format == ARM_FP16_FORMAT_IEEE)
+ return HFmode;
+ return opt_scalar_float_mode ();
+ }
return default_floatn_mode (n, extended);
}
diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c
index a104b4c..684467a 100644
--- a/gcc/config/powerpcspe/powerpcspe.c
+++ b/gcc/config/powerpcspe/powerpcspe.c
@@ -39199,7 +39199,7 @@ rs6000_vector_mode_supported_p (machine_mode mode)
}
/* Target hook for floatn_mode. */
-static machine_mode
+static opt_scalar_float_mode
rs6000_floatn_mode (int n, bool extended)
{
if (extended)
@@ -39213,10 +39213,10 @@ rs6000_floatn_mode (int n, bool extended)
if (TARGET_FLOAT128_KEYWORD)
return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode;
else
- return VOIDmode;
+ return opt_scalar_float_mode ();
case 128:
- return VOIDmode;
+ return opt_scalar_float_mode ();
default:
/* Those are the only valid _FloatNx types. */
@@ -39237,10 +39237,10 @@ rs6000_floatn_mode (int n, bool extended)
if (TARGET_FLOAT128_KEYWORD)
return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode;
else
- return VOIDmode;
+ return opt_scalar_float_mode ();
default:
- return VOIDmode;
+ return opt_scalar_float_mode ();
}
}
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index d39295c..e1371a1 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -35953,7 +35953,7 @@ rs6000_vector_mode_supported_p (machine_mode mode)
}
/* Target hook for floatn_mode. */
-static machine_mode
+static opt_scalar_float_mode
rs6000_floatn_mode (int n, bool extended)
{
if (extended)
@@ -35967,10 +35967,10 @@ rs6000_floatn_mode (int n, bool extended)
if (TARGET_FLOAT128_KEYWORD)
return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode;
else
- return VOIDmode;
+ return opt_scalar_float_mode ();
case 128:
- return VOIDmode;
+ return opt_scalar_float_mode ();
default:
/* Those are the only valid _FloatNx types. */
@@ -35991,10 +35991,10 @@ rs6000_floatn_mode (int n, bool extended)
if (TARGET_FLOAT128_KEYWORD)
return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode;
else
- return VOIDmode;
+ return opt_scalar_float_mode ();
default:
- return VOIDmode;
+ return opt_scalar_float_mode ();
}
}
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 20926d1..9607ff1 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -4267,22 +4267,22 @@ hook returns true for all of @code{SFmode}, @code{DFmode},
@code{XFmode} and @code{TFmode}, if such modes exist.
@end deftypefn
-@deftypefn {Target Hook} machine_mode TARGET_FLOATN_MODE (int @var{n}, bool @var{extended})
+@deftypefn {Target Hook} opt_scalar_float_mode TARGET_FLOATN_MODE (int @var{n}, bool @var{extended})
Define this to return the machine mode to use for the type
@code{_Float@var{n}}, if @var{extended} is false, or the type
-@code{_Float@var{n}x}, if @var{extended} is true. If such a type
-is not supported, return @code{VOIDmode}. The default version of this
-hook returns @code{SFmode} for @code{_Float32}, @code{DFmode} for
+@code{_Float@var{n}x}, if @var{extended} is true. If such a type is not
+supported, return @code{opt_scalar_float_mode ()}. The default version of
+this hook returns @code{SFmode} for @code{_Float32}, @code{DFmode} for
@code{_Float64} and @code{_Float32x} and @code{TFmode} for
@code{_Float128}, if those modes exist and satisfy the requirements for
those types and pass @code{TARGET_SCALAR_MODE_SUPPORTED_P} and
@code{TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P}; for @code{_Float64x}, it
returns the first of @code{XFmode} and @code{TFmode} that exists and
satisfies the same requirements; for other types, it returns
-@code{VOIDmode}. The hook is only called for values of @var{n} and
-@var{extended} that are valid according to ISO/IEC TS 18661-3:2015; that
-is, @var{n} is one of 32, 64, 128, or, if @var{extended} is false, 16 or
-greater than 128 and a multiple of 32.
+@code{opt_scalar_float_mode ()}. The hook is only called for values
+of @var{n} and @var{extended} that are valid according to
+ISO/IEC TS 18661-3:2015; that is, @var{n} is one of 32, 64, 128, or,
+if @var{extended} is false, 16 or greater than 128 and a multiple of 32.
@end deftypefn
@deftypefn {Target Hook} bool TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P (machine_mode @var{mode})
diff --git a/gcc/target.def b/gcc/target.def
index 985ddc0..1fff0e8 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -3385,20 +3385,20 @@ DEFHOOK
(floatn_mode,
"Define this to return the machine mode to use for the type \n\
@code{_Float@var{n}}, if @var{extended} is false, or the type \n\
-@code{_Float@var{n}x}, if @var{extended} is true. If such a type \n\
-is not supported, return @code{VOIDmode}. The default version of this \n\
-hook returns @code{SFmode} for @code{_Float32}, @code{DFmode} for \n\
+@code{_Float@var{n}x}, if @var{extended} is true. If such a type is not\n\
+supported, return @code{opt_scalar_float_mode ()}. The default version of\n\
+this hook returns @code{SFmode} for @code{_Float32}, @code{DFmode} for\n\
@code{_Float64} and @code{_Float32x} and @code{TFmode} for \n\
@code{_Float128}, if those modes exist and satisfy the requirements for \n\
those types and pass @code{TARGET_SCALAR_MODE_SUPPORTED_P} and \n\
@code{TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P}; for @code{_Float64x}, it \n\
returns the first of @code{XFmode} and @code{TFmode} that exists and \n\
satisfies the same requirements; for other types, it returns \n\
-@code{VOIDmode}. The hook is only called for values of @var{n} and \n\
-@var{extended} that are valid according to ISO/IEC TS 18661-3:2015; that \n\
-is, @var{n} is one of 32, 64, 128, or, if @var{extended} is false, 16 or \n\
-greater than 128 and a multiple of 32.",
- machine_mode, (int n, bool extended),
+@code{opt_scalar_float_mode ()}. The hook is only called for values\n\
+of @var{n} and @var{extended} that are valid according to\n\
+ISO/IEC TS 18661-3:2015; that is, @var{n} is one of 32, 64, 128, or,\n\
+if @var{extended} is false, 16 or greater than 128 and a multiple of 32.",
+ opt_scalar_float_mode, (int n, bool extended),
default_floatn_mode)
/* Compute cost of moving data from a register of class FROM to one of
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 1be139f..76ef7c9 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -469,12 +469,13 @@ default_libgcc_floating_mode_supported_p (machine_mode mode)
/* Return the machine mode to use for the type _FloatN, if EXTENDED is
false, or _FloatNx, if EXTENDED is true, or VOIDmode if not
supported. */
-machine_mode
+opt_scalar_float_mode
default_floatn_mode (int n, bool extended)
{
if (extended)
{
- machine_mode cand1 = VOIDmode, cand2 = VOIDmode;
+ opt_scalar_float_mode cand1, cand2;
+ scalar_float_mode mode;
switch (n)
{
case 32:
@@ -499,20 +500,21 @@ default_floatn_mode (int n, bool extended)
/* Those are the only valid _FloatNx types. */
gcc_unreachable ();
}
- if (cand1 != VOIDmode
- && REAL_MODE_FORMAT (cand1)->ieee_bits > n
- && targetm.scalar_mode_supported_p (cand1)
- && targetm.libgcc_floating_mode_supported_p (cand1))
+ if (cand1.exists (&mode)
+ && REAL_MODE_FORMAT (mode)->ieee_bits > n
+ && targetm.scalar_mode_supported_p (mode)
+ && targetm.libgcc_floating_mode_supported_p (mode))
return cand1;
- if (cand2 != VOIDmode
- && REAL_MODE_FORMAT (cand2)->ieee_bits > n
- && targetm.scalar_mode_supported_p (cand2)
- && targetm.libgcc_floating_mode_supported_p (cand2))
+ if (cand2.exists (&mode)
+ && REAL_MODE_FORMAT (mode)->ieee_bits > n
+ && targetm.scalar_mode_supported_p (mode)
+ && targetm.libgcc_floating_mode_supported_p (mode))
return cand2;
}
else
{
- machine_mode cand = VOIDmode;
+ opt_scalar_float_mode cand;
+ scalar_float_mode mode;
switch (n)
{
case 16:
@@ -545,13 +547,13 @@ default_floatn_mode (int n, bool extended)
default:
break;
}
- if (cand != VOIDmode
- && REAL_MODE_FORMAT (cand)->ieee_bits == n
- && targetm.scalar_mode_supported_p (cand)
- && targetm.libgcc_floating_mode_supported_p (cand))
+ if (cand.exists (&mode)
+ && REAL_MODE_FORMAT (mode)->ieee_bits == n
+ && targetm.scalar_mode_supported_p (mode)
+ && targetm.libgcc_floating_mode_supported_p (mode))
return cand;
}
- return VOIDmode;
+ return opt_scalar_float_mode ();
}
/* Make some target macros useable by target-independent code. */
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index c73ea0b..b065572 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -73,7 +73,7 @@ extern tree default_mangle_assembler_name (const char *);
extern bool default_scalar_mode_supported_p (machine_mode);
extern bool default_libgcc_floating_mode_supported_p (machine_mode);
-extern machine_mode default_floatn_mode (int, bool);
+extern opt_scalar_float_mode default_floatn_mode (int, bool);
extern bool targhook_words_big_endian (void);
extern bool targhook_float_words_big_endian (void);
extern bool default_float_exceptions_rounding_supported_p (void);
diff --git a/gcc/tree.c b/gcc/tree.c
index 4f56892..946ad94 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -9689,8 +9689,8 @@ build_common_tree_nodes (bool signed_char)
{
int n = floatn_nx_types[i].n;
bool extended = floatn_nx_types[i].extended;
- machine_mode mode = targetm.floatn_mode (n, extended);
- if (mode == VOIDmode)
+ scalar_float_mode mode;
+ if (!targetm.floatn_mode (n, extended).exists (&mode))
continue;
int precision = GET_MODE_PRECISION (mode);
/* Work around the rs6000 KFmode having precision 113 not