From patchwork Fri Dec 9 13:03:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 704487 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 3tZsqr62qhz9vFT for ; Sat, 10 Dec 2016 00:03: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="EieT/L53"; 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=T4/N30EmtL0t++r2Ru3RCmFrQbIPp q+Xxq8h9U/s91ybYPF0ynw8UTLofBOoG2iMismkh56sbViX53YMJehkXSpf0S5if toSQRYEOGhIm/FyQIRvU1far7LQtq0xV7vB5l7E9tK+0WKMaWcxCPxghJy3s1Y0y nqmMAqB/R+qlBg= 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=dGZhXDtW9jNOOEyEJUmkRxLExF8=; b=Eie T/L53iJYywEMGzAalW82dt0gP0XpNYHvzJZjbz0w660WQ6SuqfrJK2mU/1euRw5+ TJpfqLV13UvmVMKwBMUHK+tYfv9eBXaRkB/zqcvkNTfpB+Uw44FC9uLhqj6qh9l7 E1COp3MCbAgCDL83FSKMtckAg4Fu3BYFegHirPSA= Received: (qmail 48752 invoked by alias); 9 Dec 2016 13:03:45 -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 48741 invoked by uid 89); 9 Dec 2016 13:03:44 -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=pods, 6497 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:03:34 +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 3A8D7707; Fri, 9 Dec 2016 05:03:33 -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 72B9A3F477 for ; Fri, 9 Dec 2016 05:03:32 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [16/67] Add scalar_int_mode_pod References: <87h96dp8u6.fsf@e105548-lin.cambridge.arm.com> Date: Fri, 09 Dec 2016 13:03:30 +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: <87k2b9mezh.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 a POD class for scalar integers, as an instance of a new pod_mode template. Later patches will use pod_mode in situations that really do need to be POD; in this patch we're simply using PODs to remove load-time initialisation. gcc/ 2016-11-24 Richard Sandiford Alan Hayward David Sherwood * coretypes.h (pod_mode): New type. (scalar_int_mode_pod): New typedef. * machmode.h (pod_mode): New class. (int_n_data_t::m): Change type to scalar_int_mode_pod. * genmodes.c (emit_mode_int_n): Update accordingly. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 6dc3e88..5073f35 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -61,6 +61,8 @@ class scalar_float_mode; template class opt_mode; typedef opt_mode opt_scalar_int_mode; typedef opt_mode opt_scalar_float_mode; +template class pod_mode; +typedef pod_mode scalar_int_mode_pod; /* Subclasses of rtx_def, using indentation to show the class hierarchy, along with the relevant invariant. diff --git a/gcc/genmodes.c b/gcc/genmodes.c index eddbff7..8ee0fae6 100644 --- a/gcc/genmodes.c +++ b/gcc/genmodes.c @@ -1799,7 +1799,7 @@ emit_mode_int_n (void) m = mode_sort[i]; printf(" {\n"); tagged_printf ("%u", m->int_n, m->name); - printf ("E_%smode,", m->name); + printf ("{ E_%smode },", m->name); printf(" },\n"); } diff --git a/gcc/machmode.h b/gcc/machmode.h index 8c8dd54..bf568c9 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -247,6 +247,17 @@ opt_mode::exists (U *mode) const return false; } +/* A POD version of mode class T. */ + +template +struct pod_mode +{ + machine_mode_enum m_mode; + ALWAYS_INLINE operator machine_mode_enum () const { return m_mode; } + ALWAYS_INLINE operator T () const { return T::from_int (m_mode); } + ALWAYS_INLINE pod_mode &operator = (const T &m) { m_mode = m; return *this; } +}; + /* Return true if mode M has type T. */ template @@ -649,7 +660,7 @@ extern void init_adjust_machine_modes (void); struct int_n_data_t { /* These parts are initailized by genmodes output */ unsigned int bitsize; - machine_mode_enum m; + scalar_int_mode_pod m; /* RID_* is RID_INTN_BASE + index into this array */ };