From patchwork Wed Jun 21 12:59:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 9801829 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 5997960234 for ; Wed, 21 Jun 2017 13:24:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 476E62855A for ; Wed, 21 Jun 2017 13:24:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39E90285C6; Wed, 21 Jun 2017 13:24:43 +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 9D28E2855A for ; Wed, 21 Jun 2017 13:24:42 +0000 (UTC) Received: from localhost ([::1]:53948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNfce-0005Ef-Do for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Jun 2017 09:24:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNfED-0008Ed-FR for qemu-devel@nongnu.org; Wed, 21 Jun 2017 08:59:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNfEC-0008V9-PD for qemu-devel@nongnu.org; Wed, 21 Jun 2017 08:59:25 -0400 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:34301) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNfEC-0008Uf-H5 for qemu-devel@nongnu.org; Wed, 21 Jun 2017 08:59:24 -0400 Received: by mail-lf0-x244.google.com with SMTP id l200so9421751lfg.1 for ; Wed, 21 Jun 2017 05:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3NLzeipQ5BH4jA/WwfsqH7uS7CoDn8xtRrqi1tbMW4o=; b=ORTYL1KbSotdbI8AhlS6PAMawXREKr9qv6pLcBlOZvAYWVAQ0N8nUY2xT8sppyQhpU e1mVkeUG95AjL7iiQjzs/9R0QMZr17zCjRiPH8Pv2ZQO3n/JqLt842pfIclfotHuvfcs 7Me644afq0RGXd/s47eRcCx/IJ76759+HTQ8V+s1Ei7thZuqrfYPt6uS91od6H1bPdXx rgaxVQwzNi7JZS13DSgEx5GiMam7zxCoI6BHUIX4NIuu8TSjY44rq2ImZdhFvsooI233 9iVddzycFeBX0oRJDsEQIDGvmxS79I4rZ0HiDzeJ446fms2JB7L/jsLo675ymeMsb0jN xnUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3NLzeipQ5BH4jA/WwfsqH7uS7CoDn8xtRrqi1tbMW4o=; b=kiudn1TUAgrB1luIcz80/0aNGCxGMvZA5xGVGzr59tC5oZsqQRve7ldN9d6OURRbvo Z9qsQJ9/YLx8bCO2vvE7sL0mhXew0fz1KAIRO4rh8GCETt28kP84uGLOKpZgetxSnpiN WzlkCbNiTLhC/lnEE8KyLE52zbVpj9kMTeKE27ZseKIXb1oUmVwFvWXB65ILZarc/Nyq Lzb4qzeE7wnpMXtEdFMYWapsUrAbbf+V2whs1ZSAqmOry9xJV1bWBUB+ZZKs2NYvRc4i 4zEmK5o78qIzrnAMYbotHqjvqLNo8CjtVf83G4X0YBEtne8W5UwgDJgy0g1rnMj/LyhD zvqA== X-Gm-Message-State: AKS2vOwgAiSBGCY0t80KfrW8s9720BR97+I0AUfp/cTr4RerRQvQmtqw oub3TMEFSau0/Z/U X-Received: by 10.25.27.2 with SMTP id b2mr9983416lfb.24.1498049963008; Wed, 21 Jun 2017 05:59:23 -0700 (PDT) Received: from localhost (81-231-233-234-no56.tbcn.telia.com. [81.231.233.234]) by smtp.gmail.com with ESMTPSA id u11sm3793227lja.7.2017.06.21.05.59.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 05:59:22 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Date: Wed, 21 Jun 2017 14:59:13 +0200 Message-Id: <1498049955-28646-6-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498049955-28646-1-git-send-email-edgar.iglesias@gmail.com> References: <1498049955-28646-1-git-send-email-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::244 Subject: [Qemu-devel] [PATCH v2 5/7] target-microblaze: dec_barrel: Add BSEFI 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: sai.pavan.boddu@xilinx.com, edgar.iglesias@xilinx.com, alistai@xilinx.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Edgar E. Iglesias" Add support for BSEFI. Signed-off-by: Edgar E. Iglesias --- target/microblaze/translate.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 6ee4885..3fad13c 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -660,7 +660,8 @@ static void dec_div(DisasContext *dc) static void dec_barrel(DisasContext *dc) { TCGv t0; - bool s, t; + unsigned int imm_w, imm_s; + bool s, t, e = false; if ((dc->tb_flags & MSR_EE_FLAG) && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) @@ -670,27 +671,44 @@ static void dec_barrel(DisasContext *dc) return; } + if (dc->type_b) { + /* Insert and extract are only available in immediate mode. */ + e = extract32(dc->imm, 14, 1); + } s = extract32(dc->imm, 10, 1); t = extract32(dc->imm, 9, 1); + imm_w = extract32(dc->imm, 6, 5); + imm_s = extract32(dc->imm, 0, 5); - LOG_DIS("bs%s%s r%d r%d r%d\n", + LOG_DIS("bs%s%s%s r%d r%d r%d\n", + e ? "e" : "", s ? "l" : "r", t ? "a" : "l", dc->rd, dc->ra, dc->rb); - t0 = tcg_temp_new(); + if (e) { + if (imm_w + imm_s > 32 || imm_w == 0) { + /* These inputs have an undefined behavior. */ + qemu_log_mask(LOG_GUEST_ERROR, "bsefi: Bad input w=%d s=%d\n", + imm_w, imm_s); + } else { + tcg_gen_extract_i32(cpu_R[dc->rd], cpu_R[dc->ra], imm_s, imm_w); + } + } else { + t0 = tcg_temp_new(); - tcg_gen_mov_tl(t0, *(dec_alu_op_b(dc))); - tcg_gen_andi_tl(t0, t0, 31); + tcg_gen_mov_tl(t0, *(dec_alu_op_b(dc))); + tcg_gen_andi_tl(t0, t0, 31); - if (s) { - tcg_gen_shl_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0); - } else { - if (t) { - tcg_gen_sar_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0); + if (s) { + tcg_gen_shl_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0); } else { - tcg_gen_shr_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0); + if (t) { + tcg_gen_sar_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0); + } else { + tcg_gen_shr_tl(cpu_R[dc->rd], cpu_R[dc->ra], t0); + } } + tcg_temp_free(t0); } - tcg_temp_free(t0); } static void dec_bit(DisasContext *dc)