From patchwork Thu Jul 13 08:44:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107602 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1928185qge; Thu, 13 Jul 2017 01:44:46 -0700 (PDT) X-Received: by 10.98.193.197 with SMTP id i188mr59514250pfg.215.1499935486472; Thu, 13 Jul 2017 01:44:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935486; cv=none; d=google.com; s=arc-20160816; b=FRCgwHvRJGUI63Gp85/5j+dZ/OFqjxEiTHd6tRn3vn39UswmcM8OQfqUZuSqcVjMD5 ZIE7JuTLdDML3SgH6ozC3gHnlmawbBZXr2mHsMuBPN5gldw2eUcOBzGzGbtN1usYTbfK CGSAlwxH00r57rZ/o7OOmfdgueAlSO3In4jy8YRbSxV+32VFjaqCUQT8QXv3X/PTPyC0 il9RcSvmKsNZkpmI6TuB6aCyE7BY8jf3cPjEAI1djAhGM9qHfOJ2Amd4coxr5USlSTuN nVDdJjjecNU9nqzY3sHoUJloMK57NQWs5zfqL8iRNlr9dm7zs9VlB5CkmUS31lhR2wuE r2GQ== 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=lQK04C0E1H1zdFkE3WH+UA1Ow6/s7hiqhYtRMdfFCjE=; b=A8aOrg4bwSAhNQmGOexmZ60x8hkgGdgk7kY2qT4Qi7C6aDcA5QtN22ua+88ryLPfJz 3v0jU+tMuv+ZBvDlGQK1VuEeDkvw6vv/SpTMoEsupcZSAaGQayWprqqCCMkaeqVhIbCO yiUk8fcYH+3CS5YB3azG1unYKzLy4DtsbeEbYJAx1XCBrppsesIGE1NFNODObLuIQmFd ELZ75U7yPZ/dI4uliAuTyyf0VzZ42nY/KP24eyD9BEGu+KBrw3D4wdm0OpspFmfEuTnI UAztyo/o3obIrWR0vvLidaIExClxZ3GH8gjfXTQsjdA1VqkS64m6O2J01OPgr/JQ6PvE 0kpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=cIhXSmM5; spf=pass (google.com: domain of gcc-patches-return-458006-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458006-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 z44si4027090plh.218.2017.07.13.01.44.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:44:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458006-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=cIhXSmM5; spf=pass (google.com: domain of gcc-patches-return-458006-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458006-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=QPM1NTm+x5UeSSUDfRk4EfR/3WpzX LQWDfxhOyOwGmO8+DxwBq6PktyArjxNMikxf2JXDhk7XLVi+xNnzBV3dku7REA69 u3M+PCh2Sdg7PR2Flo6op5koQ4gatM4IOXjFjdKQ3vHjx8ZJ6Fmewo5AMrvUC6zo HM7iDanR9+/LIQ= 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=tkLH2vOFzGvJpYcsuCEjJ/LVsD8=; b=cIh XSmM5bXoTtPNN+m89hIj5ybZBVfbf6hpYAUhF9OThqNPFb0nZFsramrHlmoI+xdf KnNKJ1qOYi0cNqO+Nyc7QbxMt3X6nhl70g6evWyurdhkWO1V/TW/qRAVXUb7IyBy 2DZcs/oWk33JoDogsJSaZN4d+Etf73fEnSEEfQPA= Received: (qmail 58074 invoked by alias); 13 Jul 2017 08:44:28 -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 57651 invoked by uid 89); 13 Jul 2017 08:44:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=6487 X-HELO: mail-wr0-f179.google.com Received: from mail-wr0-f179.google.com (HELO mail-wr0-f179.google.com) (209.85.128.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:44:23 +0000 Received: by mail-wr0-f179.google.com with SMTP id 77so49569817wrb.1 for ; Thu, 13 Jul 2017 01:44:23 -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=lQK04C0E1H1zdFkE3WH+UA1Ow6/s7hiqhYtRMdfFCjE=; b=eFB9PHTpdIm1TDzGT57P1x5cKJFIVBDeeRIiq48gOnVsei3FgkicMmivfoMRPZylhw VX/Bcw2RqrZk/mMHpe6LZWXNOFV9O893J4YecZRmjIYkIRsk8HOfzryjm0kac6rvk7+1 9fYFxqmYIoJGaRikUrPTCVORhTyZp3mfOrpwQIL+HqNsbREZuLrF82wTN5FvM5OkRh8q wRfic1NBEzoCmPA2wzHv61gLuTvxgMU+VHnXOpce1doqRyXBlo3eB766gMg9SPXB5jc4 xf6VibdKfIJF90aouzDbk34A76gmlYDU/coSTqvEiKALZdLfVbSDFlDmoy7t7kglsk50 3Lgg== X-Gm-Message-State: AIVw110o8d6LHi+O1SObDUBqosNcQKwShIPBg++9AOqQobecrUqQIAdl l8vSwa353UUgklRdkQj5+Q== X-Received: by 10.223.142.143 with SMTP id q15mr862865wrb.180.1499935461342; Thu, 13 Jul 2017 01:44:21 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id h6sm4665373wmf.31.2017.07.13.01.44.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:44:20 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [16/77] Add scalar_int_mode_pod References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:44:19 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <878tjslo9o.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (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; this patch is simply using PODs to remove load-time initialisation. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * 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. * lower-subreg.h (target_lower_subreg): Change type to scalar_int_mode_pod. * gdbhooks.py (build_pretty_printer): Handle pod_mode and scalar_int_mode_pod. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:28.023771640 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:28.587718194 +0100 @@ -60,6 +60,8 @@ typedef const struct rtx_def *const_rtx; 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. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:28.024771545 +0100 +++ gcc/machmode.h 2017-07-13 09:18:28.588718099 +0100 @@ -294,6 +294,19 @@ opt_mode::exists (U *mode) const return false; } +/* A POD version of mode class T. */ + +template +struct pod_mode +{ + typedef typename mode_traits::from_int from_int; + + machine_mode m_mode; + ALWAYS_INLINE operator machine_mode () const { return m_mode; } + ALWAYS_INLINE operator T () const { return 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 @@ -648,7 +661,7 @@ #define HWI_COMPUTABLE_MODE_P(MODE) \ struct int_n_data_t { /* These parts are initailized by genmodes output */ unsigned int bitsize; - machine_mode m; + scalar_int_mode_pod m; /* RID_* is RID_INTN_BASE + index into this array */ }; Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-13 09:18:28.024771545 +0100 +++ gcc/genmodes.c 2017-07-13 09:18:28.587718194 +0100 @@ -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"); } Index: gcc/lower-subreg.h =================================================================== --- gcc/lower-subreg.h 2017-02-23 19:54:15.000000000 +0000 +++ gcc/lower-subreg.h 2017-07-13 09:18:28.588718099 +0100 @@ -43,7 +43,7 @@ struct lower_subreg_choices { /* Target-specific information for the subreg lowering pass. */ struct target_lower_subreg { /* An integer mode that is twice as wide as word_mode. */ - machine_mode x_twice_word_mode; + scalar_int_mode_pod x_twice_word_mode; /* What we have decided to do when optimizing for size (index 0) and speed (index 1). */ Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:28.024771545 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:18:28.587718194 +0100 @@ -545,6 +545,10 @@ def build_pretty_printer(): pp.add_printer_for_types(['opt_scalar_int_mode', 'opt_scalar_float_mode'], 'opt_mode', OptMachineModePrinter) + pp.add_printer_for_regex(r'pod_mode<(\S+)>', + 'pod_mode', MachineModePrinter) + pp.add_printer_for_types(['scalar_int_mode_pod'], + 'pod_mode', MachineModePrinter) for mode in 'scalar_int_mode', 'scalar_float_mode': pp.add_printer_for_types([mode], mode, MachineModePrinter)