From patchwork Fri Dec 9 13:41:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 704562 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 3tZtgZ2BQCz9vDh for ; Sat, 10 Dec 2016 00:41:45 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="yADUbBl2"; 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=PcHqaN3MZwnFp/tQo6V5Z1OFCMhrH xmStEzXCdx0z8GxWzsWJsHQF+PJ2/2rk8B+Cyv7ZZ4aeAUg2Whi+79EyxmFKOCiK Hu3b77JdMt2EZ3gV+pv9Ja6ky5KezYBmjIMy9fSDULrdDypQ1tCv+/2i9eU6tvXO ijTWDOb8OI+A7M= 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=CG9FrL0MmSO/qQfyNuXK+sUvU+o=; b=yAD UbBl2sY4m0CC5JuRsLvUbTrXraY854XaoChKQbpdhCV/CytT4iAQATeaIsNlOJlP e8Awlk4NgTNqF+Y/txhz7YGTJutSP2MQQsW2t5qj+cVJ02TkG74aNkpk60tKj8mX nb9IF18KYbPQJSVgrrTPPo/hRPe4BwgTodQHwoyo= Received: (qmail 25915 invoked by alias); 9 Dec 2016 13:41:37 -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 25889 invoked by uid 89); 9 Dec 2016 13:41:36 -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= 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:41:26 +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 D70EB707; Fri, 9 Dec 2016 05:41:24 -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 836EB3F477 for ; Fri, 9 Dec 2016 05:41:22 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [67/67] Add a complex_mode class References: <87h96dp8u6.fsf@e105548-lin.cambridge.arm.com> Date: Fri, 09 Dec 2016 13:41:20 +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: <87fulxdxtr.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 This patch adds another machine_mode_enum 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. gcc/ 2016-11-24 Richard Sandiford Alan Hayward David Sherwood * coretypes.h (complex_mode): New type. (opt_complex_mode): New typedef. * machmode.h (complex_mode): New class. (complex_mode::includes_p): New function. (complex_mode::from_int): Likewise. (is_complex_int_mode): Likewise. * genmodes.c (get_mode_class): Handle complex mode classes. * function.c (expand_function_end): Use is_complex_int_mode. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 564d7fe..276127f 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -59,10 +59,12 @@ class machine_mode; 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; typedef opt_mode opt_scalar_float_mode; +typedef opt_mode opt_complex_mode; template class pod_mode; typedef pod_mode scalar_mode_pod; typedef pod_mode scalar_int_mode_pod; diff --git a/gcc/function.c b/gcc/function.c index 7da0203..9d2f6bb 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -5502,6 +5502,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)); @@ -5542,8 +5543,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; diff --git a/gcc/genmodes.c b/gcc/genmodes.c index 4f10632..05376ca 100644 --- a/gcc/genmodes.c +++ b/gcc/genmodes.c @@ -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; } diff --git a/gcc/machmode.h b/gcc/machmode.h index fe62965..fd93cb0 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -433,6 +433,40 @@ scalar_mode::from_int (int i) return machine_mode_enum (i); } +/* Represents a machine mode that is known to be a COMPLEX_MODE_P. */ +class complex_mode +{ +public: + ALWAYS_INLINE complex_mode () {} + ALWAYS_INLINE operator machine_mode_enum () const { return m_mode; } + + static bool includes_p (machine_mode_enum); + static complex_mode from_int (int); + +PROTECT_ENUM_CONVERSION: + ALWAYS_INLINE complex_mode (machine_mode_enum m) : m_mode (m) {} + +protected: + machine_mode_enum m_mode; +}; + +/* Return true if M is a complex_mode. */ + +inline bool +complex_mode::includes_p (machine_mode_enum m) +{ + return COMPLEX_MODE_P (m); +} + +/* Return M as a complex_mode. This function should only be used by + utility functions; general code should use as_a instead. */ + +ALWAYS_INLINE complex_mode +complex_mode::from_int (int i) +{ + return machine_mode_enum (i); +} + /* Represents a general machine mode (scalar or non-scalar). */ class machine_mode { @@ -780,6 +814,21 @@ is_float_mode (machine_mode mode, T *float_mode) 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::from_int (mode); + return true; + } + return false; +} + namespace mode_iterator { /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */