From patchwork Tue Dec 1 15:28:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 550937 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 E0145140291 for ; Wed, 2 Dec 2015 02:46:46 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Qif3MDcF; 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:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=IBxcJ/JOZfgNnxw1/b/8Htm/0pOT6OpPITywgOYwlNjq5Lk+65VtB 3n5F4+eTTPEvICaVTqNCkmqMKUKl5Ytqw1ZtZhP0fiO6fdI0ZN8C7ukbijutIsVM Zk1MDFiQCtdGFUrckXtZycL8PwF0KLU5Z3+OPYlyx1HzjOioLlYJGE= 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:cc:subject:date:message-id:in-reply-to:references; s= default; bh=1AKHUOFSsrG6cayVuVH/8tt6HF8=; b=Qif3MDcFyqDg3MuUejuf H1XAbOQeFKhU8ugS/Vs69s8amjoHpzBf1/1Kwm2ycTBMYuf1Ux/k/A9pas+AD5tO cQ0mkSP01U0PddA9dSdU/1KWRjtheToEi5xijFhZnSGp/BkXcvHxChgnPI7EBFQx 4U/0SF56gZhPGW4fRHQlyrg= Received: (qmail 30485 invoked by alias); 1 Dec 2015 15:46:39 -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 30473 invoked by uid 89); 1 Dec 2015 15:46:38 -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_50, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 01 Dec 2015 15:46:37 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3mr3-0006An-00 for gcc-patches@gcc.gnu.org; Tue, 01 Dec 2015 10:28:38 -0500 Received: from smtp.ispras.ru ([83.149.199.79]:49331) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3mr2-0006AU-O9 for gcc-patches@gcc.gnu.org; Tue, 01 Dec 2015 10:28:32 -0500 Received: from condor.intra.ispras.ru (unknown [83.149.199.91]) by smtp.ispras.ru (Postfix) with ESMTP id BDA3620413; Tue, 1 Dec 2015 18:28:28 +0300 (MSK) Received: by condor.intra.ispras.ru (Postfix, from userid 23246) id 2CD3C1225DB9; Tue, 1 Dec 2015 18:28:28 +0300 (MSK) From: Alexander Monakov To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek , Bernd Schmidt , Dmitry Melnik Subject: [gomp-nvptx 3/9] nvptx backend: add two more identifier maps Date: Tue, 1 Dec 2015 18:28:21 +0300 Message-Id: <1448983707-18854-4-git-send-email-amonakov@ispras.ru> In-Reply-To: <1448983707-18854-1-git-send-email-amonakov@ispras.ru> References: <1448983707-18854-1-git-send-email-amonakov@ispras.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.79 X-IsSubscribed: yes This allows to rewrite libgcc wrappers in C by adding back-maps __nvptx_real_malloc -> malloc and __nvptx_real_free -> free. While at it, I've made the implementation leaner. * config/nvptx/nvptx.c (nvptx_name_replacement): Rewrite. Add __nvptx_real_malloc -> malloc and __nvptx_real_free -> free replacements. --- gcc/config/nvptx/nvptx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 9209b47..3bd3cf7 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -538,14 +538,14 @@ write_function_decl_and_comment (std::stringstream &s, const char *name, const_t static const char * nvptx_name_replacement (const char *name) { - if (strcmp (name, "call") == 0) - return "__nvptx_call"; - if (strcmp (name, "malloc") == 0) - return "__nvptx_malloc"; - if (strcmp (name, "free") == 0) - return "__nvptx_free"; - if (strcmp (name, "realloc") == 0) - return "__nvptx_realloc"; + static const char *const replacements[] = { + "malloc", "__nvptx_malloc", "free", "__nvptx_free", + "realloc", "__nvptx_realloc", "call", "__nvptx_call", + "__nvptx_real_malloc", "malloc", "__nvptx_real_free", "free" + }; + for (size_t i = 0; i < ARRAY_SIZE (replacements) / 2; i++) + if (!strcmp (name, replacements[2 * i])) + return replacements[2 * i + 1]; return name; }