From patchwork Thu Jul 13 09:05:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107663 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1948055qge; Thu, 13 Jul 2017 02:07:57 -0700 (PDT) X-Received: by 10.84.229.6 with SMTP id b6mr8703810plk.247.1499936877332; Thu, 13 Jul 2017 02:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936877; cv=none; d=google.com; s=arc-20160816; b=zmiBFVzBUBq11USSBq2lIiyuuWEJy8KKpaKcpLky0Z0yDOADayQVGKitMkovggL8Et SWU62hr7UyJGrGnYmgGLFY0+W3ONpssAIYyOaZpmi0EplSMSo3JbznNyAZ7sA62iC5z4 RoSwBPDSuSP2xwobOANhzT4qNlU+6idOJkYNZgn6DyPKkoJxlNsAVQfaDexH7B4UYErp Crv2QCfrz3Mvz47by4b0JU5HGWMzebBRr6rGrF6N4OjuP51FFaD5Cj4Q5fMxuMAhZmSE M2fxMbXg1aEodrO4SCSrJQj75WTew7IteiYB/5tLI9S3QQed/dQkeev3/F75tqfy+4A3 1EMA== 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=fZ8IRbC2K8pdUvECqqWi8K08yCx4V8YVzVfrMMfxgpE=; b=xfCZ7IE4v6fImZH8dofQcxjBnR7CMkCEsmgT7J5nqowrM6bZNQ6w6AnAxwam8hBJny 7VqCxx7OAh6H6Jh3XCxWqkDgHPfYPoHmZa+8uf5O5YMql2Mi3CniPefnecDUpZiy+z3M G8+Y2h4Nj632knHlMRyzg3yiEE31DKOgqNe3+p35Kc6rB4oVQ6mSkJLUNqjhzfjsHwJn tRKaoBvXTGbuKXx+ata/6C7j5j0V+IEKOEASAl4x+SV49gChUajLFLjzbP8hCMJTANq1 7s3oRcfI3G8hCVjCrK5gH7UMPOTuyElYlqoJbagT5N1SolAELOtivmWGF3M/KQGi6ibK 8bVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=xVRdcpEL; spf=pass (google.com: domain of gcc-patches-return-458069-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458069-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 q20si3797883pfq.106.2017.07.13.02.07.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:07:57 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458069-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=xVRdcpEL; spf=pass (google.com: domain of gcc-patches-return-458069-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458069-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=QVBfvz5K3gBkfPv9pohmHy/adI3ws H/CGrl5xdCYg58Cgh6eXc1hT+37xY58faF08bZMPqHJxsCDifxPeF7i52EaCiUEW mgM7GxjjKIZM5mJuRTsKVfqo8nAlKFl0+DulG4HXF6QdXvs6rjZwicxpghtzJMuI dykgmvEbyz4uJc= 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=iydBQtYAnrzv8OXXHzwiyinSvF8=; b=xVR dcpEL7ofIR43pR8F2/uyikMdd57Q/4TwLTG1j/dXgsj8Q5YlIceBbdcnZhIzv7iu HFi3DHND8UIkY+0qy8xtpJjtvHVYBJHHsGb4GNRaGGWQkKTnPUbGL2/wVbo1qdwV fLHm13RI+bqJ4c/VYzxrefDdPFC9OyI0gEeYswTY= Received: (qmail 96697 invoked by alias); 13 Jul 2017 09:05:44 -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 95839 invoked by uid 89); 13 Jul 2017 09:05:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 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-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:05:37 +0000 Received: by mail-wm0-f44.google.com with SMTP id f67so18680730wmh.1 for ; Thu, 13 Jul 2017 02:05:37 -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=fZ8IRbC2K8pdUvECqqWi8K08yCx4V8YVzVfrMMfxgpE=; b=RkQOYdgB4W6t/QtsF5w8fL1cAAtIkKMe6+sIx9GZs7i3ufEINclkuDewL54oTgiHo+ hS7jBjdQIwZEJJStOrtyLzAiQxdYBKqmhULs38OErOHPCJQIFLufEAHczXTkuXeWjaOj rTblSyTYASgZDACtOT0Uk4+RbFHVclVv2DkCbBLXnF+5ggnFczEdncEV2FJeWir5bwtN h7Pm7QTThnuZd8Itttswkk8rVilfxGNSPUPhQl3Ut7cZKiWLfDvxnvlWAUCMiFcb+mwG kuyQqcMqkycsNox4+1M/y7dYOICRmI4mFYbRWDaTAsuAuh3sCZrHtQbZbqI26eOmfMS4 Wj7A== X-Gm-Message-State: AIVw112YEVQXcxDVT4TchrkBGbNl2wo+IU7IGLx/dvGjQMPIUvXMUzVr /ty0SRsQ5UljUuTjiAaxAg== X-Received: by 10.28.138.8 with SMTP id m8mr1306033wmd.40.1499936735339; Thu, 13 Jul 2017 02:05:35 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 143sm5854038wmg.9.2017.07.13.02.05.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:05:34 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [77/77] Add a complex_mode class References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:05:33 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87wp7caeqq.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds another machine_mode wrapper for modes that are known to be COMPLEX_MODE_P. There aren't yet many places that make use of it, but that might change in future. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (complex_mode): New type. * gdbhooks.py (build_pretty_printer): Handle it. * machmode.h (complex_mode): New class. (complex_mode::includes_p): New function. (is_complex_int_mode): Likewise. (is_complex_float_mode): Likewise. * genmodes.c (get_mode_class): Handle complex mode classes. * function.c (expand_function_end): Use is_complex_int_mode. gcc/go/ * go-lang.c (go_langhook_type_for_mode): Use is_complex_float_mode. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:19:00.088160188 +0100 +++ gcc/coretypes.h 2017-07-13 09:19:00.526129740 +0100 @@ -58,6 +58,7 @@ typedef const struct rtx_def *const_rtx; class scalar_mode; class scalar_int_mode; class scalar_float_mode; +class complex_mode; template class opt_mode; typedef opt_mode opt_scalar_mode; typedef opt_mode opt_scalar_int_mode; @@ -323,6 +324,7 @@ #define const_tree union _dont_use_tree_ typedef struct scalar_mode scalar_mode; typedef struct scalar_int_mode scalar_int_mode; typedef struct scalar_float_mode scalar_float_mode; +typedef struct complex_mode complex_mode; #endif Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:19:00.090160049 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:19:00.527129670 +0100 @@ -551,7 +551,8 @@ def build_pretty_printer(): pp.add_printer_for_types(['scalar_int_mode_pod', 'scalar_mode_pod'], 'pod_mode', MachineModePrinter) - for mode in 'scalar_mode', 'scalar_int_mode', 'scalar_float_mode': + for mode in ('scalar_mode', 'scalar_int_mode', 'scalar_float_mode', + 'complex_mode'): pp.add_printer_for_types([mode], mode, MachineModePrinter) return pp Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:19:00.090160049 +0100 +++ gcc/machmode.h 2017-07-13 09:19:00.528129601 +0100 @@ -451,6 +451,30 @@ scalar_mode::includes_p (machine_mode m) } } +/* Represents a machine mode that is known to be a COMPLEX_MODE_P. */ +class complex_mode +{ +public: + typedef mode_traits::from_int from_int; + + ALWAYS_INLINE complex_mode () {} + ALWAYS_INLINE complex_mode (from_int m) : m_mode (machine_mode (m)) {} + ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + static bool includes_p (machine_mode); + +protected: + machine_mode m_mode; +}; + +/* Return true if M is a complex_mode. */ + +inline bool +complex_mode::includes_p (machine_mode m) +{ + return COMPLEX_MODE_P (m); +} + /* Return the base GET_MODE_SIZE value for MODE. */ ALWAYS_INLINE unsigned short @@ -770,6 +794,36 @@ is_float_mode (machine_mode mode, T *flo return true; } return false; +} + +/* Return true if MODE has class MODE_COMPLEX_INT, storing it as + a complex_mode in *CMODE if so. */ + +template +inline bool +is_complex_int_mode (machine_mode mode, T *cmode) +{ + if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT) + { + *cmode = complex_mode (complex_mode::from_int (mode)); + return true; + } + return false; +} + +/* Return true if MODE has class MODE_COMPLEX_FLOAT, storing it as + a complex_mode in *CMODE if so. */ + +template +inline bool +is_complex_float_mode (machine_mode mode, T *cmode) +{ + if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT) + { + *cmode = complex_mode (complex_mode::from_int (mode)); + return true; + } + return false; } namespace mode_iterator Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-13 09:18:53.274650323 +0100 +++ gcc/genmodes.c 2017-07-13 09:19:00.527129670 +0100 @@ -1152,6 +1152,10 @@ get_mode_class (struct mode_data *mode) case MODE_DECIMAL_FLOAT: return "scalar_float_mode"; + case MODE_COMPLEX_INT: + case MODE_COMPLEX_FLOAT: + return "complex_mode"; + default: return NULL; } Index: gcc/function.c =================================================================== --- gcc/function.c 2017-07-13 09:18:53.273650396 +0100 +++ gcc/function.c 2017-07-13 09:19:00.527129670 +0100 @@ -5503,6 +5503,7 @@ expand_function_end (void) : DECL_REGISTER (decl_result)) { rtx real_decl_rtl = crtl->return_rtx; + complex_mode cmode; /* This should be set in assign_parms. */ gcc_assert (REG_FUNCTION_VALUE_P (real_decl_rtl)); @@ -5543,8 +5544,8 @@ expand_function_end (void) need to generate some non-trivial bitfield insertions. Do that on a pseudo and not the hard register. */ else if (GET_CODE (decl_rtl) == CONCAT - && GET_MODE_CLASS (GET_MODE (decl_rtl)) == MODE_COMPLEX_INT - && GET_MODE_BITSIZE (GET_MODE (decl_rtl)) <= BITS_PER_WORD) + && is_complex_int_mode (GET_MODE (decl_rtl), &cmode) + && GET_MODE_BITSIZE (cmode) <= BITS_PER_WORD) { int old_generating_concat_p; rtx tmp; Index: gcc/go/go-lang.c =================================================================== --- gcc/go/go-lang.c 2017-07-13 09:18:31.699428322 +0100 +++ gcc/go/go-lang.c 2017-07-13 09:19:00.527129670 +0100 @@ -384,7 +384,7 @@ go_langhook_type_for_mode (machine_mode scalar_int_mode imode; scalar_float_mode fmode; - enum mode_class mc = GET_MODE_CLASS (mode); + complex_mode cmode; if (is_int_mode (mode, &imode)) return go_langhook_type_for_size (GET_MODE_BITSIZE (imode), unsignedp); else if (is_float_mode (mode, &fmode)) @@ -402,9 +402,9 @@ go_langhook_type_for_mode (machine_mode return long_double_type_node; } } - else if (mc == MODE_COMPLEX_FLOAT) + else if (is_complex_float_mode (mode, &cmode)) { - switch (GET_MODE_BITSIZE (mode)) + switch (GET_MODE_BITSIZE (cmode)) { case 64: return complex_float_type_node; @@ -413,7 +413,7 @@ go_langhook_type_for_mode (machine_mode default: // We have to check for long double in order to support // i386 excess precision. - if (mode == TYPE_MODE(complex_long_double_type_node)) + if (cmode == TYPE_MODE(complex_long_double_type_node)) return complex_long_double_type_node; } }