From patchwork Wed Jan 20 17:26:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 570808 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 E4FA71402D9 for ; Thu, 21 Jan 2016 04:27:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=fY5RMrmH; 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:date:message-id:in-reply-to:references; q=dns; s= default; b=Vy6A3wmCqTe9Lu/hb1pzv5vX1Mgk7ksz24huQK9f9YXWv1TS8QWX5 adog1tSWns6p0cCeaMBQD5ksSjZpE/8oIF+OCeTSeFYcHrcf/2BRgWcArja+Gz1T Os+rsydpwW67D0m7s8/EBCq7uVRKHlscFcC/tlI1Bh/VhFAuFoRCzo= 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:date:message-id:in-reply-to:references; s=default; bh=VbNF0D2+ih2ILvlTN00Fx4l2bY0=; b=fY5RMrmHPA43c6afZW7Aa3KbSjCi XcZwneWV1kawLLv+6kvL5h1Dm7DeRh1+9oF3ogIPs4yA/g81vZ6jLi6sUo45sD0n VWXY9SgqLNqgoDzc8c77FW3XbI2PScaIjRlPxQxq/UiBq1fvQX93Djm3MRyAbjFx uKGGIEynRiLkmtI= Received: (qmail 823 invoked by alias); 20 Jan 2016 17:27:13 -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 774 invoked by uid 89); 20 Jan 2016 17:27:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=sk:attribu, tree_constant, TREE_CONSTANT, Hx-languages-length:2315 X-HELO: smtp.ispras.ru Received: from smtp.ispras.ru (HELO smtp.ispras.ru) (83.149.199.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Jan 2016 17:27:11 +0000 Received: from condor.intra.ispras.ru (unknown [83.149.199.91]) by smtp.ispras.ru (Postfix) with ESMTP id 0DF7520407 for ; Wed, 20 Jan 2016 20:27:08 +0300 (MSK) Received: by condor.intra.ispras.ru (Postfix, from userid 23246) id EAB751225E1C; Wed, 20 Jan 2016 20:27:07 +0300 (MSK) From: Alexander Monakov To: gcc-patches@gcc.gnu.org Subject: [gomp-nvptx 04/13] nvptx backend: add support for placing variables in shared memory Date: Wed, 20 Jan 2016 20:26:58 +0300 Message-Id: <1453310827-23183-5-git-send-email-amonakov@ispras.ru> In-Reply-To: <1453310827-23183-1-git-send-email-amonakov@ispras.ru> References: <1453310827-23183-1-git-send-email-amonakov@ispras.ru> X-IsSubscribed: yes This patch allows to use __attribute__((shared)) to place non-automatic variables in shared memory. * config/nvptx/nvptx.c (nvptx_encode_section_info): Handle "shared" attribute. (nvptx_handle_shared_attribute): New. Use it... (nvptx_attribute_table): ... here (new entry). --- gcc/ChangeLog.gomp-nvptx | 7 +++++++ gcc/config/nvptx/nvptx.c | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index f63f840..5c8c28b 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -228,9 +228,12 @@ nvptx_encode_section_info (tree decl, rtx rtl, int first) if (TREE_CONSTANT (decl)) area = DATA_AREA_CONST; else if (TREE_CODE (decl) == VAR_DECL) - /* TODO: This would be a good place to check for a .shared or - other section name. */ - area = TREE_READONLY (decl) ? DATA_AREA_CONST : DATA_AREA_GLOBAL; + { + if (lookup_attribute ("shared", DECL_ATTRIBUTES (decl))) + area = DATA_AREA_SHARED; + else + area = TREE_READONLY (decl) ? DATA_AREA_CONST : DATA_AREA_GLOBAL; + } SET_SYMBOL_DATA_AREA (XEXP (rtl, 0), area); } @@ -4047,12 +4050,36 @@ nvptx_handle_kernel_attribute (tree *node, tree name, tree ARG_UNUSED (args), return NULL_TREE; } +/* Handle a "shared" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +nvptx_handle_shared_attribute (tree *node, tree name, tree ARG_UNUSED (args), + int ARG_UNUSED (flags), bool *no_add_attrs) +{ + tree decl = *node; + + if (TREE_CODE (decl) != VAR_DECL) + { + error ("%qE attribute only applies to variables", name); + *no_add_attrs = true; + } + else if (current_function_decl && !TREE_STATIC (decl)) + { + error ("%qE attribute only applies to non-stack variables", name); + *no_add_attrs = true; + } + + return NULL_TREE; +} + /* Table of valid machine attributes. */ static const struct attribute_spec nvptx_attribute_table[] = { /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler, affects_type_identity } */ { "kernel", 0, 0, true, false, false, nvptx_handle_kernel_attribute, false }, + { "shared", 0, 0, true, false, false, nvptx_handle_shared_attribute, false }, { NULL, 0, 0, false, false, false, NULL, false } };