From patchwork Fri Aug 24 19:44:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev\" via" X-Patchwork-Id: 10575893 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D54E1579 for ; Fri, 24 Aug 2018 20:48:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BAF22CC7A for ; Fri, 24 Aug 2018 20:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 378522CC8E; Fri, 24 Aug 2018 20:48:30 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 B9AD32CC7A for ; Fri, 24 Aug 2018 20:48:29 +0000 (UTC) Received: from localhost ([::1]:43582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ftJ0P-0000fJ-2G for patchwork-qemu-devel@patchwork.kernel.org; Fri, 24 Aug 2018 16:48:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ftI3y-0000Wq-Uw for qemu-devel@nongnu.org; Fri, 24 Aug 2018 15:48:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ftI3r-0006uK-2N for qemu-devel@nongnu.org; Fri, 24 Aug 2018 15:48:04 -0400 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:61405) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1ftI3o-0006nX-L8 for qemu-devel@nongnu.org; Fri, 24 Aug 2018 15:47:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1535140076; x=1566676076; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=9n+OHt8dYUoI13/H2cUNLUhUabURPBBFMnq5IPTZT8M=; b=I3N5AVRSq9KQlZPJ+n49EsbjwyQ7YjfdHWdK/n8VmcBt35m/6b8tzUBC DUv5LcmpoVxqLtEaUoW5o6toCNjZoFYpFId+3Nm2Kay6DbB3V60KTZg3o Skdv2Qb9AyveUevLhG5yJczUszma1KgPmtrhqMkrE9tcLxjecJkaXiii3 0=; X-IronPort-AV: E=Sophos;i="5.53,283,1531785600"; d="scan'208";a="755714004" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-2a-e7be2041.us-west-2.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Aug 2018 19:45:34 +0000 Received: from ua08cfde8192f59f8a244.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2a-e7be2041.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w7OJigBK128597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 24 Aug 2018 19:44:43 GMT Received: from ua08cfde8192f59f8a244.ant.amazon.com (localhost [127.0.0.1]) by ua08cfde8192f59f8a244.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id w7OJigPS020010; Fri, 24 Aug 2018 15:44:42 -0400 Received: (from jancraig@localhost) by ua08cfde8192f59f8a244.ant.amazon.com (8.15.2/8.15.2/Submit) id w7OJig3q020009; Fri, 24 Aug 2018 15:44:42 -0400 To: qemu-devel@nongnu.org Date: Fri, 24 Aug 2018 15:44:04 -0400 Message-Id: <8c9d8af290bc2086b6d685632bc49806cfd40d0a.1535133089.git.jancraig@amazon.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Precedence: Bulk X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 207.171.184.25 X-Mailman-Approved-At: Fri, 24 Aug 2018 16:47:11 -0400 Subject: [Qemu-devel] [PATCH 3/7] target/mips: Add MXU instruction S8LDD X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Craig Janeczek via Qemu-devel From: "Denis V. Lunev\" via" Reply-To: Craig Janeczek Cc: aurelien@aurel32.net, amarkovic@wavecomp.com, Craig Janeczek Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Adds support for emulating the S8LDD MXU instruction. Signed-off-by: Craig Janeczek --- target/mips/translate.c | 82 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index 381dfad36e..4ccccd5849 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -365,6 +365,7 @@ enum { OPC_DCLZ = 0x24 | OPC_SPECIAL2, OPC_DCLO = 0x25 | OPC_SPECIAL2, /* MXU */ + OPC_MXU_S8LDD = 0x22 | OPC_SPECIAL2, OPC_MXU_S32I2M = 0x2F | OPC_SPECIAL2, OPC_MXU_S32M2I = 0x2E | OPC_SPECIAL2, /* Special */ @@ -3784,14 +3785,24 @@ typedef union { uint32_t:5; uint32_t special2:6; } S32M2I; + + struct { + uint32_t op:6; + uint32_t xra:4; + uint32_t s8:8; + uint32_t optn3:3; + uint32_t rb:5; + uint32_t special2:6; + } S8LDD; } MXU_OPCODE; /* MXU Instructions */ static void gen_mxu(DisasContext *ctx, uint32_t opc) { #ifndef TARGET_MIPS64 /* Only works in 32 bit mode */ - TCGv t0; + TCGv t0, t1; t0 = tcg_temp_new(); + t1 = tcg_temp_new(); MXU_OPCODE *opcode = (MXU_OPCODE *)&ctx->opcode; switch (opc) { @@ -3804,9 +3815,77 @@ static void gen_mxu(DisasContext *ctx, uint32_t opc) gen_load_mxu_gpr(t0, opcode->S32M2I.xra); gen_store_gpr(t0, opcode->S32M2I.rb); break; + + case OPC_MXU_S8LDD: + gen_load_gpr(t0, opcode->S8LDD.rb); + tcg_gen_movi_tl(t1, opcode->S8LDD.s8); + tcg_gen_ext8s_tl(t1, t1); + tcg_gen_add_tl(t0, t0, t1); + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_SB); + switch (opcode->S8LDD.optn3) { + case 0: /*XRa[7:0] = tmp8 */ + tcg_gen_andi_tl(t1, t1, 0xFF); + gen_load_mxu_gpr(t0, opcode->S8LDD.xra); + tcg_gen_andi_tl(t0, t0, 0xFFFFFF00); + tcg_gen_or_tl(t0, t0, t1); + break; + case 1: /* XRa[15:8] = tmp8 */ + tcg_gen_andi_tl(t1, t1, 0xFF); + gen_load_mxu_gpr(t0, opcode->S8LDD.xra); + tcg_gen_andi_tl(t0, t0, 0xFFFF00FF); + tcg_gen_shli_tl(t1, t1, 8); + tcg_gen_or_tl(t0, t0, t1); + break; + case 2: /* XRa[23:16] = tmp8 */ + tcg_gen_andi_tl(t1, t1, 0xFF); + gen_load_mxu_gpr(t0, opcode->S8LDD.xra); + tcg_gen_andi_tl(t0, t0, 0xFF00FFFF); + tcg_gen_shli_tl(t1, t1, 16); + tcg_gen_or_tl(t0, t0, t1); + break; + case 3: /* XRa[31:24] = tmp8 */ + tcg_gen_andi_tl(t1, t1, 0xFF); + gen_load_mxu_gpr(t0, opcode->S8LDD.xra); + tcg_gen_andi_tl(t0, t0, 0x00FFFFFF); + tcg_gen_shli_tl(t1, t1, 24); + tcg_gen_or_tl(t0, t0, t1); + break; + case 4: /* XRa = {8'b0, tmp8, 8'b0, tmp8} */ + tcg_gen_andi_tl(t1, t1, 0xFF); + tcg_gen_mov_tl(t0, t1); + tcg_gen_shli_tl(t1, t1, 16); + tcg_gen_or_tl(t0, t0, t1); + break; + case 5: /* XRa = {tmp8, 8'b0, tmp8, 8'b0} */ + tcg_gen_andi_tl(t1, t1, 0xFF); + tcg_gen_shli_tl(t1, t1, 8); + tcg_gen_mov_tl(t0, t1); + tcg_gen_shli_tl(t1, t1, 16); + tcg_gen_or_tl(t0, t0, t1); + break; + case 6: /* XRa = {{8{sign of tmp8}}, tmp8, {8{sign of tmp8}}, tmp8} */ + tcg_gen_mov_tl(t0, t1); + tcg_gen_andi_tl(t0, t0, 0xFF00FFFF); + tcg_gen_shli_tl(t1, t1, 16); + tcg_gen_or_tl(t0, t0, t1); + break; + case 7: /* XRa = {tmp8, tmp8, tmp8, tmp8} */ + tcg_gen_andi_tl(t1, t1, 0xFF); + tcg_gen_mov_tl(t0, t1); + tcg_gen_shli_tl(t1, t1, 8); + tcg_gen_or_tl(t0, t0, t1); + tcg_gen_shli_tl(t1, t1, 8); + tcg_gen_or_tl(t0, t0, t1); + tcg_gen_shli_tl(t1, t1, 8); + tcg_gen_or_tl(t0, t0, t1); + break; + } + gen_store_mxu_gpr(t0, opcode->S8LDD.xra); + break; } tcg_temp_free(t0); + tcg_temp_free(t1); #else generate_exception_end(ctx, EXCP_RI); #endif @@ -17895,6 +17974,7 @@ static void decode_opc_special2_legacy(CPUMIPSState *env, DisasContext *ctx) case OPC_MXU_S32I2M: case OPC_MXU_S32M2I: + case OPC_MXU_S8LDD: gen_mxu(ctx, op1); break;