From patchwork Thu Sep 8 22:31:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Rolnik X-Patchwork-Id: 9322255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0095660231 for ; Thu, 8 Sep 2016 22:48:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEF3729A36 for ; Thu, 8 Sep 2016 22:48:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3F6829A38; Thu, 8 Sep 2016 22:48:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 05AF529A36 for ; Thu, 8 Sep 2016 22:48:33 +0000 (UTC) Received: from localhost ([::1]:54507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi87U-00008A-6W for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Sep 2016 18:48:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi7sO-0003E4-DZ for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:32:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bi7sL-0000jp-SC for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:32:55 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:32927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi7sL-0000jh-JF for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:32:53 -0400 Received: by mail-wm0-x242.google.com with SMTP id b187so209334wme.0 for ; Thu, 08 Sep 2016 15:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EImmKBZEmhtR3eGvmPxk4PIGlaUZiG5Imz5sgI72/Rs=; b=rB1gDCXrsHZJ519zzdhBeTVpe1XznOYIB6zoWKw4i4a5bTyKmZAGY648FqvNJnt8Rj IuMoHi8fglwgZNRWirjIv/Oikf3jC9UClVTczntbhlxxpwPlbE89x1+nD9Jkr4j0RyMt fdiDOZk/Y8uplPmzMsfS0oAbLmxrN/5Cxo9kRwRoQV2WPXYcrdUga6fYjDQ3m+Uf2FvC avnUF1cf4SOt4fE2qjJEzUVPQqBxWhUuZIrjBG4tZIZnuAypxBnJ7rAZbZqPURIGND8v ShIAZ1sNhEHLBO4z04RagrwfhMW6rWHcdpNfm8kq9Npisk9hNoMQGoQS78VmYXQyj2zC CwoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EImmKBZEmhtR3eGvmPxk4PIGlaUZiG5Imz5sgI72/Rs=; b=fr+3q/ZsplMXAivL+CRNqKDn3LxfBrL+vd+mWoTFU2HLmFd2a9i7exnxmG5iHg+Zi/ k387RpcXYEEUMcJDf+BWv49l5lyOT/bigX/N8rieKY9orhEUmBE7tbC9toNIa9my2G5b h0InqtQsu3AaE+y+OeDrqnlAeLdIBX3ObVcZ1Xy/mAQLq0ZwY1dKqnGejmMdR541729Y Sz3LphgK9BJYY7HJfwA3pqu34x/dIlqLlHx3MziIuFA4MFvlXMZIRFixDXxffqetp3Cl JwdBmWW84mOQr7+3c1atlcnctiZ/1iiH3iN1fNA9Catv4f6EDiGkLvg0LjSXx70aM18Q MYqg== X-Gm-Message-State: AE9vXwNED4nHDCWEtseeZco6eky+0h3VhV8+Eixm2uzgMmuVGFfRTnzhmUeCSm8IKn4YZQ== X-Received: by 10.28.55.67 with SMTP id e64mr2312537wma.107.1473373972804; Thu, 08 Sep 2016 15:32:52 -0700 (PDT) Received: from a0999b0126e1.ant.amazon.com ([94.230.86.12]) by smtp.gmail.com with ESMTPSA id d8sm276298wmi.0.2016.09.08.15.32.51 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 08 Sep 2016 15:32:51 -0700 (PDT) From: Michael Rolnik To: qemu-devel@nongnu.org Date: Fri, 9 Sep 2016 01:31:54 +0300 Message-Id: <1473373930-31547-14-git-send-email-mrolnik@gmail.com> X-Mailer: git-send-email 2.4.9 (Apple Git-60) In-Reply-To: <1473373930-31547-1-git-send-email-mrolnik@gmail.com> References: <1473373930-31547-1-git-send-email-mrolnik@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH RFC v1 13/29] target-arc: NORM, NORMW X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Rolnik Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Michael Rolnik --- target-arc/Makefile.objs | 1 + target-arc/helper.h | 3 ++ target-arc/op_helper.c | 91 +++++++++++++++++++++++++++++++++++++++++++++ target-arc/translate-inst.c | 52 ++++++++++++++++++++++++++ target-arc/translate-inst.h | 4 ++ 5 files changed, 151 insertions(+) create mode 100644 target-arc/op_helper.c diff --git a/target-arc/Makefile.objs b/target-arc/Makefile.objs index 6fdb000..cd3eebc 100644 --- a/target-arc/Makefile.objs +++ b/target-arc/Makefile.objs @@ -21,6 +21,7 @@ obj-y += translate.o obj-y += helper.o obj-y += cpu.o +obj-y += op_helper.o obj-y += translate-inst.o obj-y += gdbstub.o obj-y += decode.o diff --git a/target-arc/helper.h b/target-arc/helper.h index 69c91fb..d480052 100644 --- a/target-arc/helper.h +++ b/target-arc/helper.h @@ -19,3 +19,6 @@ */ DEF_HELPER_1(debug, void, env) +DEF_HELPER_2(norm, i32, env, i32) +DEF_HELPER_2(normw, i32, env, i32) + diff --git a/target-arc/op_helper.c b/target-arc/op_helper.c new file mode 100644 index 0000000..f372bbf --- /dev/null +++ b/target-arc/op_helper.c @@ -0,0 +1,91 @@ +/* + * QEMU ARC CPU + * + * Copyright (c) 2016 Michael Rolnik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "exec/helper-proto.h" +#include "exec/ioport.h" + +#define AUX_ID_STATUS 0x000 +#define AUX_ID_SEMAPHORE 0x001 +#define AUX_ID_LP_START 0x002 +#define AUX_ID_LP_END 0x003 +#define AUX_ID_IDENTITY 0x004 +#define AUX_ID_DEBUG 0x005 +#define AUX_ID_PC 0x006 + +#define AUX_ID_STATUS32 0x00A +#define AUX_ID_STATUS32_L1 0x00B +#define AUX_ID_STATUS32_L2 0x00C + +#define AUX_ID_MULHI 0x012 + +#define AUX_ID_INT_VECTOR_BASE 0x025 + +#define AUX_ID_INT_MACMODE 0x041 + +#define AUX_ID_IRQ_LV12 0x043 + +#define AUX_ID_IRQ_LEV 0x200 +#define AUX_ID_IRQ_HINT 0x201 + +#define AUX_ID_ERET 0x400 +#define AUX_ID_ERBTA 0x401 +#define AUX_ID_ERSTATUS 0x402 +#define AUX_ID_ECR 0x403 +#define AUX_ID_EFA 0x404 + +#define AUX_ID_ICAUSE1 0x40A +#define AUX_ID_ICAUSE2 0x40B +#define AUX_ID_IENABLE 0x40C +#define AUX_ID_ITRIGGER 0x40D + +#define AUX_ID_BTA 0x412 +#define AUX_ID_BTA_L1 0x413 +#define AUX_ID_BTA_L2 0x414 +#define AUX_ID_IRQ_PULSE_CANSEL 0x415 +#define AUX_ID_IRQ_PENDING 0x416 + +target_ulong helper_norm(CPUARCState *env, uint32_t src1) +{ + if (src1 == 0x00000000 || src1 == 0xffffffff) { + return 31; + } else { + if ((src1 & 0x80000000) == 0x80000000) { + src1 = ~src1; + } + return clz32(src1) - 1; + } +} + +target_ulong helper_normw(CPUARCState *env, uint32_t src1) +{ + src1 &= 0xffff; + + if (src1 == 0x0000 || src1 == 0xffff) { + return 15; + } else { + if ((src1 & 0x8000) == 0x8000) { + src1 = ~src1 & 0xffff; + } + return clz32(src1) - 17; + } +} + diff --git a/target-arc/translate-inst.c b/target-arc/translate-inst.c index a0d601e..00785bf 100644 --- a/target-arc/translate-inst.c +++ b/target-arc/translate-inst.c @@ -1365,3 +1365,55 @@ int arc_gen_RRC(DisasCtxt *ctx, TCGv dest, TCGv src1) return BS_NONE; } +/* + NORMW +*/ +int arc_gen_NORMW(DisasCtxt *ctx, TCGv dest, TCGv src1) +{ + TCGv rslt = dest; + + if (TCGV_EQUAL(dest, src1)) { + rslt = tcg_temp_new_i32(); + } + + gen_helper_normw(rslt, cpu_env, src1); + + if (ctx->opt.f) { + tcg_gen_setcond_tl(TCG_COND_EQ, cpu_Zf, src1, ctx->zero); + tcg_gen_shri_tl(cpu_Nf, src1, 31); + } + + if (!TCGV_EQUAL(dest, rslt)) { + tcg_gen_mov_tl(dest, rslt); + tcg_temp_free_i32(rslt); + } + + return BS_NONE; +} + +/* + NORM +*/ +int arc_gen_NORM(DisasCtxt *ctx, TCGv dest, TCGv src1) +{ + TCGv rslt = dest; + + if (TCGV_EQUAL(dest, src1)) { + rslt = tcg_temp_new_i32(); + } + + gen_helper_norm(rslt, cpu_env, src1); + + if (ctx->opt.f) { + tcg_gen_setcond_tl(TCG_COND_EQ, cpu_Zf, src1, ctx->zero); + tcg_gen_shri_tl(cpu_Nf, src1, 31); + } + + if (!TCGV_EQUAL(dest, rslt)) { + tcg_gen_mov_tl(dest, rslt); + tcg_temp_free_i32(rslt); + } + + return BS_NONE; +} + diff --git a/target-arc/translate-inst.h b/target-arc/translate-inst.h index 5e1c52d..811c914 100644 --- a/target-arc/translate-inst.h +++ b/target-arc/translate-inst.h @@ -86,3 +86,7 @@ int arc_gen_BXOR(DisasCtxt *c, TCGv dest, TCGv src1, TCGv src2); int arc_gen_RRC(DisasCtxt *c, TCGv dest, TCGv src1); int arc_gen_RLC(DisasCtxt *c, TCGv dest, TCGv src1); + +int arc_gen_NORMW(DisasCtxt *c, TCGv dest, TCGv src1); +int arc_gen_NORM(DisasCtxt *c, TCGv dest, TCGv src1); +