From patchwork Thu Jun 2 16:26:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 632771 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 3rQRnG4Qtrz9sDG for ; Fri, 10 Jun 2016 00:01:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=n2PGydAg; 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 :resent-from:resent-date:resent-message-id:resent-to:message-id :in-reply-to:references:from:date:subject:to; q=dns; s=default; b= Y5+oXVi1zDL+hF0YQUcGbTd6EC/Vye1pGnQIHxUoNI4BnGO/kimNb8Gy6H0vwOQw TGWSLtQm8omNIFxlj3M0CLK99Z2aAwtwUWHYwaA/h+llatqqqNRK9Yi6sknxCg9t O5IWYq7o4+62NFNzrRLMAff6DzxRHLCu77YYjNggSI0= 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 :resent-from:resent-date:resent-message-id:resent-to:message-id :in-reply-to:references:from:date:subject:to; s=default; bh=2s73 J9pNXxkiFBlaSMp6fkyjzBk=; b=n2PGydAgJkLaUZ3EmnGkRbnPiejK1oOLAYnh 53+SYzbjJ3/KDuNzaZ0E4RGbJ8shgbvSiqOypjQaXxKW+0XLFPbEO51tZw6tnFqv 5oZ4wUHHL57zNjRzQwKdgkNQpt4swZoteqhpJ0v4WA7nREm7k5htTJlGNZbShXlY dhTCI6I= Received: (qmail 88993 invoked by alias); 9 Jun 2016 14:01:19 -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 88882 invoked by uid 89); 9 Jun 2016 14:01:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=moments X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 09 Jun 2016 14:01:03 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 61816ADB9 for ; Thu, 9 Jun 2016 14:01:00 +0000 (UTC) Resent-From: Martin Jambor Resent-Date: Thu, 9 Jun 2016 16:01:00 +0200 Resent-Message-ID: <20160609140100.GB15281@virgil.suse.cz> Resent-To: GCC Patches Message-Id: <0765386b6735918b3d2367166cfb50a087c5ec28.1465479214.git.mjambor@suse.cz> In-Reply-To: References: From: Martin Jambor Date: Thu, 2 Jun 2016 18:26:42 +0200 Subject: [hsa-branch 1/5] Allow putting local variables into group and global segments To: GCC Patches X-IsSubscribed: yes Hi, the following patch adds the capability to put local HSA variables into the group or global segment as indicated by new declaration attributes. In the process I had to fix how we differentiate between local and global attributes because context and allocation properties now can diverge. This patch does not do the things necessary to expose the attributes to the user. I wonder whether it even makes sense for OpenMP uses. I will do so when we provide the users with a more direct way of generating HSAIL. I will commit the patch to the HSA branch in a few moments. The ultimate goal is trunk but I'd like to keep it there for a number of weeks. Martin 2016-06-02 Martin Jambor * hsa-gen.c (get_symbol_for_decl): Fix dinstinguishing between global and local functions. Put local variables into a segment according to their attribute or static flag, if there is one. --- gcc/hsa-gen.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c index c08f4a8..2ead76a 100644 --- a/gcc/hsa-gen.c +++ b/gcc/hsa-gen.c @@ -794,8 +794,8 @@ get_symbol_for_decl (tree decl) dummy.m_decl = decl; - bool is_in_global_vars - = TREE_CODE (decl) == VAR_DECL && is_global_var (decl); + bool is_in_global_vars = ((TREE_CODE (decl) == VAR_DECL) + && !decl_function_context (decl)); if (is_in_global_vars) slot = hsa_global_variable_symbols->find_slot (&dummy, INSERT); @@ -861,8 +861,17 @@ get_symbol_for_decl (tree decl) /* PARM_DECL and RESULT_DECL should be already in m_local_symbols. */ gcc_assert (TREE_CODE (decl) == VAR_DECL); - sym = new hsa_symbol (BRIG_TYPE_NONE, BRIG_SEGMENT_PRIVATE, - BRIG_LINKAGE_FUNCTION); + BrigSegment8_t segment; + if (lookup_attribute ("hsa_group_segment", DECL_ATTRIBUTES (decl))) + segment = BRIG_SEGMENT_GROUP; + else if (TREE_STATIC (decl) + || lookup_attribute ("hsa_global_segment", + DECL_ATTRIBUTES (decl))) + segment = BRIG_SEGMENT_GLOBAL; + else + segment = BRIG_SEGMENT_PRIVATE; + + sym = new hsa_symbol (BRIG_TYPE_NONE, segment, BRIG_LINKAGE_FUNCTION); sym->m_align = align; sym->fillup_for_decl (decl); hsa_cfun->m_private_variables.safe_push (sym);