From patchwork Thu Jul 13 08:43:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107599 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1927167qge; Thu, 13 Jul 2017 01:43:34 -0700 (PDT) X-Received: by 10.99.114.73 with SMTP id c9mr8218138pgn.267.1499935414245; Thu, 13 Jul 2017 01:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935414; cv=none; d=google.com; s=arc-20160816; b=pQVjE1RmoKYRKM1VuVKRB9rVqvwBHsUtiNP6p1bE0ibzhc2fUrMl4+b4hehDuTOHcB vLYZufHmpQVJpJHi7Cv6cCaSuD8CgWaqmj0TGrhl8b/f8tE9RCj95Q+cMBY8BZkFOto+ V/+pzLNzWtuHqE39X0GY6/qIHBeLgNin2xe4GOZtzY3vTSLh/RQBM/0F6uYatxTasz/v IK4jhvOtPaEAnOdNQjufia1hO3hDkGTkjj97tBn7w+gNsp/7q1huVS5TeAiDeekoeSgs +UmyOEZtvFqKtGom6d2ch/cZ7BTATMglop/M6MSpFOad+cxhzcDu5DmzUYXSqMZOzZP0 KrZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=yJbwjzRGAIw6UwkT19goiKXGyj5LTOf1uR/FSYjWZms=; b=kWAzuQgw5HSogQJWQHSK9npDkxawLEN5yA0gX014EjRtFn28BRRLm+iMTFZ2n4XA6Q l7IqY6+9F+xoTDMwrYtqoT4Y5jefltMLQRb28WuD53TyKQECXEzBA7Vnv8hhty1bhnc8 PGLQm0vm3mxFtobnT0CyoXtLlBAAPKmdmMWJ6WsLNN+420j776dYgQcujb4SxgNnUgRe lErGNTCMcId4Xx3X5QZtNyXNDBTiSGazL5Yk6gRpM8JGAvOpj1T9KHGaWtad5b6ljrWL Yoy0shmxbTGlzZ84m+H/6hNjuWmT0vVDJyHP9nq5iTVOLp0cWHWG++9Cs0c9V/t633wy j3QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=krtXhVfN; spf=pass (google.com: domain of gcc-patches-return-458003-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458003-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o4si3845859pgf.492.2017.07.13.01.43.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:43:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458003-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=krtXhVfN; spf=pass (google.com: domain of gcc-patches-return-458003-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458003-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=jXrrqrCAP0D2ILllp0eJiWhyHQRHR sOgVj+5SRl8q7vgU3oARzArpRMlj91b8ddZ/l7CyKO7Hc46eRyjpAx6nNUMA59iY hR+z8GTceXxGA+t1vG906AehLY4hYqtQLgzxJHNikCpp+qgW6DDk5qCoqqxxnhFg ZxtwZ5JX7+jbXQ= 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=Pl326g/Ku/29q9Hgjnin5OjaDD0=; b=krt XhVfNeHXifAMTBmvaKJh3ORwvj2BurzHqTDx06RWz51s4URQ4ma4Pm5Zr+1ShJbE EOku4zPLD6IzfjI7VM8QXrv5J8JTCxDDaKerwMEvwqxD9hyzcJpoHd790ITKMJuJ tWInSEt7F/RRIVfHU8M0KbXMXZtZnr854TKOtwgg= Received: (qmail 12653 invoked by alias); 13 Jul 2017 08:43:17 -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 12316 invoked by uid 89); 13 Jul 2017 08:43:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:43:12 +0000 Received: by mail-wm0-f41.google.com with SMTP id f67so18052197wmh.1 for ; Thu, 13 Jul 2017 01:43:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=yJbwjzRGAIw6UwkT19goiKXGyj5LTOf1uR/FSYjWZms=; b=uEO1LyyQSsflSmUyCkA5K4h+DH6Sv9cjGBt0Sm3FpuAcMHtRaxII50jafs16Bj4QXv ZIH0RjRbEsgxuivhKH8lvdOA6pQRq9c6okvlFuF8X/+CkGT5eBVt0yvMVJosAZ3Zyhlc ZY5vuGMwN/sOL9C1fqJM48iu/qsFGN2AVMnBx1A8jMcQS8oGx3zRBJUChk4/kEmdleId p29udq66vCvqh7aIlYOw5zuT0Dkixye2hY1YtReHmp4HtBsJ78Rlfqg4DirX5ojH5OP5 ZYCmtlz+98AqGbEsvAJjSDqLBFObe7EFnIFIr8k588/Fhx6fSlHR97Bs92x/OWa+ziSZ hbeA== X-Gm-Message-State: AIVw111VxsaTSLOUAkLqZ042qrcHhdLnQiMTMbH8ntghg/T+dBu+QHgY 76bmLG+xwrIhf6tcuJuPEA== X-Received: by 10.28.49.7 with SMTP id x7mr1246886wmx.57.1499935389461; Thu, 13 Jul 2017 01:43:09 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 35sm2874411wrp.63.2017.07.13.01.43.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:43:08 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [13/77] Make floatn_mode return an opt_scalar_float_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:43:07 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87lgnslobo.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 As per subject. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood 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. Index: gcc/target.def =================================================================== --- gcc/target.def 2017-07-05 16:29:19.600761904 +0100 +++ gcc/target.def 2017-07-13 09:18:26.916877727 +0100 @@ -3374,20 +3374,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 Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi 2017-07-05 16:29:19.597161905 +0100 +++ gcc/doc/tm.texi 2017-07-13 09:18:26.914877921 +0100 @@ -4267,22 +4267,22 @@ hook returns true for all of @code{SFmod @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}) Index: gcc/config/arm/arm.c =================================================================== --- gcc/config/arm/arm.c 2017-07-13 09:18:25.327032350 +0100 +++ gcc/config/arm/arm.c 2017-07-13 09:18:26.899879373 +0100 @@ -311,7 +311,7 @@ static bool arm_asm_elf_flags_numeric (u 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[] = @@ -23653,11 +23653,15 @@ arm_excess_precision (enum excess_precis /* 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); } Index: gcc/config/powerpcspe/powerpcspe.c =================================================================== --- gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:19.102696197 +0100 +++ gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:26.902879083 +0100 @@ -39201,7 +39201,7 @@ rs6000_vector_mode_supported_p (machine_ } /* Target hook for floatn_mode. */ -static machine_mode +static opt_scalar_float_mode rs6000_floatn_mode (int n, bool extended) { if (extended) @@ -39215,10 +39215,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. */ @@ -39239,10 +39239,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 (); } } Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c 2017-07-13 09:18:19.117694534 +0100 +++ gcc/config/rs6000/rs6000.c 2017-07-13 09:18:26.909878405 +0100 @@ -36202,7 +36202,7 @@ rs6000_vector_mode_supported_p (machine_ } /* Target hook for floatn_mode. */ -static machine_mode +static opt_scalar_float_mode rs6000_floatn_mode (int n, bool extended) { if (extended) @@ -36216,10 +36216,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. */ @@ -36240,10 +36240,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 (); } } Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h 2017-07-05 16:29:19.601661904 +0100 +++ gcc/targhooks.h 2017-07-13 09:18:26.917877631 +0100 @@ -73,7 +73,7 @@ extern tree default_mangle_assembler_nam 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); Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2017-07-13 09:18:19.145691430 +0100 +++ gcc/targhooks.c 2017-07-13 09:18:26.917877631 +0100 @@ -468,12 +468,12 @@ default_libgcc_floating_mode_supported_p /* 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: @@ -498,20 +498,20 @@ default_floatn_mode (int n, bool extende /* 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: @@ -544,13 +544,13 @@ default_floatn_mode (int n, bool extende 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. */ Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-06-30 12:50:37.494697187 +0100 +++ gcc/tree.c 2017-07-13 09:18:26.920877340 +0100 @@ -10474,8 +10474,8 @@ build_common_tree_nodes (bool signed_cha { 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