From patchwork Tue Aug 25 14:22:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 510513 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 6E20B1401CB for ; Wed, 26 Aug 2015 00:22:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Js1rG6vK; 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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=n66HptPGEascLeo1FPaCgp4sd7NYEJfi7UBcgHMidZ/FZgaCbmKnX YxmJj5POXmVbK1td38q6T4pVItXNZciUq6p2YCbSSZ4jlGXJPN3Ty0hFn14uqrvH h3HuQ8t36klTo0F+WX0Nj5oePud/4ekx0K/YK+UPnbXsqLnjrJLdfA= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=1Q8mBnUBhdno2SR+dLQgi5SVgQk=; b=Js1rG6vKi05LEs0mPRvs BKQnVGNH9A/HVl3N++Zgm33sYsJPBRd1a6V65DyH9/WgbhLk1eYVfmNsnwC79UsM jKCUi77n1zJAdg72Fz9V8JqdR6JC/lF4rT/NtpNucYvOVYHmfqQ4DUD4CpaQIGw9 g8atuy1uVi+Q4iXsNFgtf5Q= Received: (qmail 59008 invoked by alias); 25 Aug 2015 14:22:14 -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 58999 invoked by uid 89); 25 Aug 2015 14:22:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 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; Tue, 25 Aug 2015 14:22:12 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 74850ACE4 for ; Tue, 25 Aug 2015 14:22:07 +0000 (UTC) Date: Tue, 25 Aug 2015 16:22:07 +0200 From: Martin Jambor To: GCC Patches Subject: [hsa] Fix omp declare target support Message-ID: <20150825142206.GE32341@virgil.suse.cz> Mail-Followup-To: GCC Patches MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, it was brought to my attention that omp declare target functions were not properly translated to HSA functions. Until the grand shceme with an IPA pass is complete, this will do. And having a single predicate to decide what should be an HSA function cannot be bad. Committed to the hsa branch. Thanks, Martin 2015-08-25 Martin Jambor * hsa.h (hsa_callable_function_p): Declare. * hsa.c (hsa_callable_function_p): New function. * hsa-gen.c (gen_hsa_insns_for_call): Use it. (pass_gen_hsail::execute): Likewise. --- gcc/ChangeLog.hsa | 7 +++++++ gcc/hsa-gen.c | 5 ++--- gcc/hsa.c | 9 +++++++++ gcc/hsa.h | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog.hsa b/gcc/ChangeLog.hsa index 4ad8414..922c917 100644 --- a/gcc/ChangeLog.hsa +++ b/gcc/ChangeLog.hsa @@ -1,5 +1,12 @@ 2015-08-25 Martin Jambor + * hsa.h (hsa_callable_function_p): Declare. + * hsa.c (hsa_callable_function_p): New function. + * hsa-gen.c (gen_hsa_insns_for_call): Use it. + (pass_gen_hsail::execute): Likewise. + +2015-08-25 Martin Jambor + * hsa-gen.c (gen_hsa_unaryop_for_builtin): New function. 2015-08-25 Martin Jambor diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c index 1e23996..7190dce 100644 --- a/gcc/hsa-gen.c +++ b/gcc/hsa-gen.c @@ -3255,7 +3255,7 @@ gen_hsa_insns_for_call (gimple stmt, hsa_bb *hbb, return; } - if (lookup_attribute ("hsafunc", DECL_ATTRIBUTES (function_decl))) + if (hsa_callable_function_p (function_decl)) gen_hsa_insns_for_direct_call (stmt, hbb, ssa_map); else if (!gen_hsa_insns_for_known_library_call (stmt, hbb, ssa_map)) sorry ("HSA does support only call for functions with 'hsafunc' " @@ -4102,8 +4102,7 @@ pass_gen_hsail::execute (function *) || lookup_attribute ("hsakernel", DECL_ATTRIBUTES (current_function_decl))) return generate_hsa (true); - else if (lookup_attribute ("hsafunc", - DECL_ATTRIBUTES (current_function_decl))) + else if (hsa_callable_function_p (current_function_decl)) return generate_hsa (false); else return wrap_all_hsa_calls (); diff --git a/gcc/hsa.c b/gcc/hsa.c index 13a2ace..4ad44fe 100644 --- a/gcc/hsa.c +++ b/gcc/hsa.c @@ -103,6 +103,15 @@ hash_table *hsa_global_variable_symbols; /* True if compilation unit-wide data are already allocated and initialized. */ static bool compilation_unit_data_initialized; +/* Return true if FNDECL represents an HSA-callable function. */ + +bool +hsa_callable_function_p (tree fndecl) +{ + return lookup_attribute ("hsafunc", DECL_ATTRIBUTES (fndecl)) + || lookup_attribute ("omp declare target", DECL_ATTRIBUTES (fndecl)); +} + /* Allocate HSA structures that are are used when dealing with different functions. */ diff --git a/gcc/hsa.h b/gcc/hsa.h index 3956676..f9bcc80 100644 --- a/gcc/hsa.h +++ b/gcc/hsa.h @@ -898,6 +898,7 @@ extern struct hsa_function_representation *hsa_cfun; extern hash_table *hsa_global_variable_symbols; extern hash_map *> *hsa_decl_kernel_dependencies; extern unsigned hsa_kernel_calls_counter; +bool hsa_callable_function_p (tree fndecl); void hsa_init_compilation_unit_data (void); void hsa_deinit_compilation_unit_data (void); bool hsa_machine_large_p (void);