From patchwork Fri Dec 9 13:01:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 704484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tZsnY0mpfz9t0q for ; Sat, 10 Dec 2016 00:01:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="N7XDB5M3"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=luqPMtXFZsgxLgpIaotiX9EYuaxN3 UOvCzY5AXqvOBptyugRE4lZhuiRE4Df/uf2viquCEhgqPpjdVHLuGu9KMCjPvRPA CL5degyX2fJSrZWvRQ3Lfg9kxvNBBrrEa4SMnip+Hi5kYj1tri0kImcf/pQ9sS5Y w3AI/55sPcIEvY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=Sb840BFybxZSItYppFf++EN6NgU=; b=N7X DB5M3pEtQtuZdTfKtyqtcu/ifW0H9ob90SqbwWlm+i2nuNRSKGERcDv8FYRBaNLm kKR7PUYXH72Z9cU1YNHB1hcT5bmeH4SXHNRk/RwRbhk4QGItwy7ggYP/0MIFPrpx 2j9COjKzg0bT3ywtWnj0QzMGx9JZaNs9zDIMP7ac= Received: (qmail 42877 invoked by alias); 9 Dec 2016 13:01:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 42813 invoked by uid 89); 9 Dec 2016 13:01:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=3770710 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Dec 2016 13:01:31 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0212D707; Fri, 9 Dec 2016 05:01:30 -0800 (PST) Received: from localhost (e105548-lin.manchester.arm.com [10.45.32.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9E1A23F477 for ; Fri, 9 Dec 2016 05:01:29 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [13/67] Make floatn_mode return an opt_scalar_float_mode References: <87h96dp8u6.fsf@e105548-lin.cambridge.arm.com> Date: Fri, 09 Dec 2016 13:01:28 +0000 In-Reply-To: <87h96dp8u6.fsf@e105548-lin.cambridge.arm.com> (Richard Sandiford's message of "Fri, 09 Dec 2016 12:48:01 +0000") Message-ID: <87wpf9mf2v.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 As per subject. gcc/ 2016-11-24 Richard Sandiford Alan Hayward David Sherwood * 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/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. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 6922c4e..45c08bf 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -303,7 +303,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[] = @@ -23372,11 +23372,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/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index e868cef..08a069d 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -37693,7 +37693,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) @@ -37707,10 +37707,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. */ @@ -37731,10 +37731,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 199ec75..187d20d 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -4258,22 +4258,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 3574ea8..09b23b2 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -3365,20 +3365,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 6178096..f8a9fae 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -467,12 +467,12 @@ 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; switch (n) { case 32: @@ -497,20 +497,20 @@ 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 () + && REAL_MODE_FORMAT (*cand1)->ieee_bits > n + && targetm.scalar_mode_supported_p (*cand1) + && targetm.libgcc_floating_mode_supported_p (*cand1)) 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 () + && REAL_MODE_FORMAT (*cand2)->ieee_bits > n + && targetm.scalar_mode_supported_p (*cand2) + && targetm.libgcc_floating_mode_supported_p (*cand2)) return cand2; } else { - machine_mode cand = VOIDmode; + opt_scalar_float_mode cand; switch (n) { case 16: @@ -543,13 +543,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 () + && REAL_MODE_FORMAT (*cand)->ieee_bits == n + && targetm.scalar_mode_supported_p (*cand) + && targetm.libgcc_floating_mode_supported_p (*cand)) 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 933b70c..7b633c2 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 da295ab..5124576 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -10427,8 +10427,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