From patchwork Thu Jan 5 14:23:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 90022 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp8992222qgi; Thu, 5 Jan 2017 06:24:11 -0800 (PST) X-Received: by 10.84.217.148 with SMTP id p20mr157762950pli.164.1483626251223; Thu, 05 Jan 2017 06:24:11 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id j15si76188842pli.53.2017.01.05.06.24.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jan 2017 06:24:11 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445460-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; spf=pass (google.com: domain of gcc-patches-return-445460-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445460-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=xLQDGzswWilbrQoaPcuJmkJqGt7sqMfJk7jeOnJL/1rCOh7+A3 GXsbW2889+TX7BlSgHsgd/vYfIhZiegZ1sOJIrNUIhIADN9+rPYJIbTCxW+f4ndX J7zuCoO9gMCe6JSWtNi7NQOBerMolnVtqOOFDxs5s1jQWehbulXV0fM3c= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=UxdzOwclp4LC9m6wxsgkrAwTEYQ=; b=jKyE8MYCz9EVG5ajuf/i gFSywGY7+ptV5j3+0Zs/y6mdfmBb6ScTxDEim4vlrMnlGVgFGUpL7Jgsw2AEuPOl Q1qLfvwpEQGjqMs8Ur4bkQF4gA57j/Sw1iYS0FreyWyntDDBMbVRVNdnjvGEHD2X VGWk/Qs1F9eo+dQ1UBc4Ims= Received: (qmail 43210 invoked by alias); 5 Jan 2017 14:23:59 -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 43069 invoked by uid 89); 5 Jan 2017 14:23:57 -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= 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 ESMTP; Thu, 05 Jan 2017 14:23:47 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 98771AAE8 for ; Thu, 5 Jan 2017 14:23:45 +0000 (UTC) To: GCC Patches Cc: Martin Jambor From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] [HSA] Implement DIVMOD internal function call Message-ID: <61d9581a-4f90-c8a9-2c33-607397e8c952@suse.cz> Date: Thu, 5 Jan 2017 15:23:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 X-IsSubscribed: yes As DIVMOD has started to be used on x86_64, HSA targets needs to understand the internal function call. It's implemented by tuple of division and remainder or arguments. It's pre-approved by Martin Jambor for both hsa branch and trunk. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Martin >From 89217a4ce213c0f9bcd4bd157f29e6bc562dd98f Mon Sep 17 00:00:00 2001 From: marxin Date: Tue, 3 Jan 2017 13:50:54 +0100 Subject: [PATCH] HSA: implement DIVMOD internal function call gcc/ChangeLog: 2017-01-03 Martin Liska * hsa-gen.c (gen_hsa_divmod): New function. (gen_hsa_insn_for_internal_fn_call): Use the function for IFN_DIVMOD. --- gcc/hsa-gen.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c index f2843b3ed38..632561d5e45 100644 --- a/gcc/hsa-gen.c +++ b/gcc/hsa-gen.c @@ -4345,6 +4345,40 @@ gen_hsa_popcount (gcall *call, hsa_bb *hbb) gen_hsa_popcount_to_dest (dest, arg, hbb); } +/* Emit instructions that implement DIVMOD builtin STMT. + Instructions are appended to basic block HBB. */ + +static void +gen_hsa_divmod (gcall *call, hsa_bb *hbb) +{ + tree lhs = gimple_call_lhs (call); + if (lhs == NULL_TREE) + return; + + tree rhs0 = gimple_call_arg (call, 0); + tree rhs1 = gimple_call_arg (call, 1); + + hsa_op_with_type *arg0 = hsa_reg_or_immed_for_gimple_op (rhs0, hbb); + hsa_op_with_type *arg1 = hsa_reg_or_immed_for_gimple_op (rhs1, hbb); + + hsa_op_reg *dest0 = new hsa_op_reg (arg0->m_type); + hsa_op_reg *dest1 = new hsa_op_reg (arg1->m_type); + + hsa_insn_basic *insn = new hsa_insn_basic (3, BRIG_OPCODE_DIV, dest0->m_type, + dest0, arg0, arg1); + hbb->append_insn (insn); + insn = new hsa_insn_basic (3, BRIG_OPCODE_REM, dest1->m_type, dest1, arg0, + arg1); + hbb->append_insn (insn); + + hsa_op_reg *dest = hsa_cfun->reg_for_gimple_ssa (lhs); + BrigType16_t src_type = hsa_bittype_for_type (dest0->m_type); + + insn = new hsa_insn_packed (3, BRIG_OPCODE_COMBINE, dest->m_type, + src_type, dest, dest0, dest1); + hbb->append_insn (insn); +} + /* Set VALUE to a shadow kernel debug argument and append a new instruction to HBB basic block. */ @@ -5050,6 +5084,10 @@ gen_hsa_insn_for_internal_fn_call (gcall *stmt, hsa_bb *hbb) gen_hsa_popcount (stmt, hbb); break; + case IFN_DIVMOD: + gen_hsa_divmod (stmt, hbb); + break; + case IFN_ACOS: case IFN_ASIN: case IFN_ATAN: -- 2.11.0