From patchwork Thu Sep 8 22:31:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Rolnik X-Patchwork-Id: 9322251 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 80BA260231 for ; Thu, 8 Sep 2016 22:47:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C6C129A37 for ; Thu, 8 Sep 2016 22:47:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5143429A39; Thu, 8 Sep 2016 22:47:08 +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 B6D2829A38 for ; Thu, 8 Sep 2016 22:47:07 +0000 (UTC) Received: from localhost ([::1]:54502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi866-0007RD-UR for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Sep 2016 18:47:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi7sG-00037b-7H for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:32:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bi7sD-0000gv-1x for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:32:48 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34874) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi7sC-0000gp-OS for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:32:44 -0400 Received: by mail-wm0-x242.google.com with SMTP id a6so200642wmc.2 for ; Thu, 08 Sep 2016 15:32:44 -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=3w9EG88aVlziO6bN2V5F7ix4cjfj1ktUnHULIKdNi3k=; b=IKLKpasC1VWvJAlCqEYy0IBWsU2ddLf89mMR+mJpOhqEuQ+VWpXEB8DamMXYslg21k Ik5IOQK77pDIaga0SiIpwNvEZ9UqFLQljA5DhJ3uZk7bbsdlvjJWK91rxDfZeYAix+Y2 UEtKBQ35wrgSnt1q8cOzVw0Oc1DIYUsyL5Tg0s4YZNcTPMqjGa6x/3C6+jcN7Lh1AkxX igCW1bwVwprIHSvlXXYyqHe0Xpfrv/bHHTno4AYKW2QnKWfyaiQdcwb5ulHDptd5Lm/V K8t+9h1To2n+e7hMnMOeJdz2G+nJ5ua1ED/AtCgkowsypI/KB83pPFKM+2gwLEU1Tuat 5HsQ== 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=3w9EG88aVlziO6bN2V5F7ix4cjfj1ktUnHULIKdNi3k=; b=LtceOhYk9BSsIm+uXDsBF5aJ07XMfzFb60uk+Ovb98Gy/LHcpLAcAB9GbKzGodAQGG d4FBZki69IZ+1qcdPvY4tgniKT1VkiYLAKBBFmLG2IzAtiiTJ0P+kRUSW04BugVZxk+B 7hnOCdzNpM3BuDcujLP9sa2stA1j3k/u8KVW7aXkpAzPCXe21VlAPEYeHG0Mo62RjQQ8 PPM+FYf7PUszcnkSdJPHK6eftbScdE1V6BNOoKpK0tVbFP3Fgtn0QrIjrWs7PXbwJI3c idPoGj6qgcBbBWlBU8MVufF88FCC33R4uq9mjKrsC1go0WrtiIpc8SR4P4YqSpqSaaI2 EOhg== X-Gm-Message-State: AE9vXwOXpBrOl8gdPFAcR50IP2qW3pBeJuVdbhOoYCIuKrDmw4yFTY1ssHHn6k0K/Tc86A== X-Received: by 10.28.140.5 with SMTP id o5mr624453wmd.13.1473373963911; Thu, 08 Sep 2016 15:32:43 -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.42 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 08 Sep 2016 15:32:43 -0700 (PDT) From: Michael Rolnik To: qemu-devel@nongnu.org Date: Fri, 9 Sep 2016 01:31:47 +0300 Message-Id: <1473373930-31547-7-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 06/29] target-arc: EX, LD, ST, SYNC, PREFETCH 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/translate-inst.c | 230 ++++++++++++++++++++++++++++++++++++++++++++ target-arc/translate-inst.h | 10 ++ 2 files changed, 240 insertions(+) diff --git a/target-arc/translate-inst.c b/target-arc/translate-inst.c index 2032823..ac13c86 100644 --- a/target-arc/translate-inst.c +++ b/target-arc/translate-inst.c @@ -664,3 +664,233 @@ int arc_gen_RORm(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2) return BS_NONE; } +/* + EX +*/ +int arc_gen_EX(DisasCtxt *ctx, TCGv dest, TCGv src1) +{ + TCGv temp = tcg_temp_new_i32(); + + tcg_gen_mov_tl(temp, dest); + + tcg_gen_qemu_ld_tl(dest, src1, ctx->memidx, MO_UL); + tcg_gen_qemu_st_tl(temp, src1, ctx->memidx, MO_UL); + + tcg_temp_free_i32(temp); + + return BS_NONE; +} + +/* + LD +*/ +int arc_gen_LD(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2) +{ + TCGv addr = tcg_temp_new_i32(); + + /* address */ + switch (ctx->opt.aa) { + case 0x00: { + tcg_gen_add_tl(addr, src1, src2); + } break; + + case 0x01: { + tcg_gen_add_tl(addr, src1, src2); + } break; + + case 0x02: { + tcg_gen_mov_tl(addr, src1); + } break; + + case 0x03: { + if (ctx->opt.zz == 0x02) { + tcg_gen_shli_tl(addr, src2, 1); + } else if (ctx->opt.zz == 0x00) { + tcg_gen_shli_tl(addr, src2, 2); + } else { + assert(!"bad format"); + } + + tcg_gen_add_tl(addr, src1, addr); + } break; + } + + /* memory read */ + switch (ctx->opt.zz) { + case 0x00: { + tcg_gen_qemu_ld_tl(dest, addr, ctx->memidx, MO_UL); + } break; + + case 0x01: { + if (ctx->opt.x) { + tcg_gen_qemu_ld_tl(dest, addr, ctx->memidx, MO_SB); + } else { + tcg_gen_qemu_ld_tl(dest, addr, ctx->memidx, MO_UB); + } + } break; + + case 0x02: { + if (ctx->opt.x) { + tcg_gen_qemu_ld_tl(dest, addr, ctx->memidx, MO_SW); + } else { + tcg_gen_qemu_ld_tl(dest, addr, ctx->memidx, MO_UW); + } + } break; + + case 0x03: { + assert(!"reserved"); + } break; + } + + /* address write back */ + if (ctx->opt.aa == 0x01 || ctx->opt.aa == 0x02) { + tcg_gen_add_tl(src1, src1, src2); + } + + tcg_temp_free_i32(addr); + + return BS_NONE; +} + +/* + LDB +*/ +int arc_gen_LDB(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2) +{ + + ctx->opt.zz = 1; /* byte */ + ctx->opt.x = 0; /* no sign extension */ + ctx->opt.aa = 0; /* no address write back */ + ctx->opt.di = 0; /* cached data memory access */ + + return arc_gen_LD(ctx, dest, src1, src2); +} + +/* + LDW +*/ +int arc_gen_LDW(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2) +{ + + ctx->opt.zz = 2; /* word */ + ctx->opt.x = 0; /* no sign extension */ + ctx->opt.aa = 0; /* no address write back */ + ctx->opt.di = 0; /* cached data memory access */ + + return arc_gen_LD(ctx, dest, src1, src2); +} + +/* + ST +*/ +int arc_gen_ST(DisasCtxt *ctx, TCGv src1, TCGv src2, TCGv src3) +{ + TCGv addr = tcg_temp_new_i32(); + + /* address */ + switch (ctx->opt.aa) { + case 0x00: { + tcg_gen_add_tl(addr, src2, src3); + } break; + + case 0x01: { + tcg_gen_add_tl(addr, src2, src3); + } break; + + case 0x02: { + tcg_gen_mov_tl(addr, src2); + } break; + + case 0x03: { + if (ctx->opt.zz == 0x02) { + tcg_gen_shli_tl(addr, src3, 1); + } else if (ctx->opt.zz == 0x00) { + tcg_gen_shli_tl(addr, src3, 2); + } else { + assert(!"bad format"); + } + + tcg_gen_add_tl(addr, src2, addr); + } break; + } + + /* write */ + switch (ctx->opt.zz) { + case 0x00: { + tcg_gen_qemu_st_tl(src1, addr, ctx->memidx, MO_UL); + } break; + + case 0x01: { + tcg_gen_qemu_st_tl(src1, addr, ctx->memidx, MO_UB); + } break; + + case 0x02: { + tcg_gen_qemu_st_tl(src1, addr, ctx->memidx, MO_UW); + } break; + + case 0x03: { + assert(!"reserved"); + } break; + } + + /* address write back */ + if (ctx->opt.aa == 0x01 || ctx->opt.aa == 0x02) { + tcg_gen_add_tl(src2, src2, src3); + } + + tcg_temp_free_i32(addr); + + return BS_NONE; +} + +/* + STB +*/ +int arc_gen_STB(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2) +{ + + ctx->opt.zz = 1; /* byte */ + ctx->opt.x = 0; /* no sign extension */ + ctx->opt.aa = 0; /* no address write back */ + ctx->opt.di = 0; /* cached data memory access */ + + return arc_gen_ST(ctx, dest, src1, src2); +} + +/* + STW +*/ +int arc_gen_STW(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2) +{ + + ctx->opt.zz = 2; /* word */ + ctx->opt.x = 0; /* no sign extension */ + ctx->opt.aa = 0; /* no address write back */ + ctx->opt.di = 0; /* cached data memory access */ + + return arc_gen_ST(ctx, dest, src1, src2); +} + +/* + PREFETCH +*/ +int arc_gen_PREFETCH(DisasCtxt *ctx, TCGv src1, TCGv src2) +{ + TCGv temp = tcg_temp_new_i32(); + + arc_gen_LD(ctx, temp, src1, src2); + + tcg_temp_free_i32(temp); + + return BS_NONE; +} + +/* + SYNC +*/ +int arc_gen_SYNC(DisasCtxt *ctx) +{ + /* nothing to do*/ + + return BS_NONE; +} diff --git a/target-arc/translate-inst.h b/target-arc/translate-inst.h index 325f708..0038645 100644 --- a/target-arc/translate-inst.h +++ b/target-arc/translate-inst.h @@ -51,3 +51,13 @@ int arc_gen_LSRm(DisasCtxt *c, TCGv dest, TCGv src1, TCGv src2); int arc_gen_ROR(DisasCtxt *c, TCGv dest, TCGv src1); int arc_gen_RORm(DisasCtxt *c, TCGv dest, TCGv src1, TCGv src2); +int arc_gen_EX(DisasCtxt *c, TCGv dest, TCGv src1); +int arc_gen_LD(DisasCtxt *c, TCGv dest, TCGv src1, TCGv src2); +int arc_gen_LDW(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2); +int arc_gen_LDB(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2); +int arc_gen_ST(DisasCtxt *c, TCGv src1, TCGv src2, TCGv src3); +int arc_gen_STW(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2); +int arc_gen_STB(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2); +int arc_gen_PREFETCH(DisasCtxt *c, TCGv src1, TCGv src2); +int arc_gen_SYNC(DisasCtxt *c); +