Received: from eggs.gnu.org ([140.186.70.92]:34313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkYvc-0003TN-47 for qemu-devel@nongnu.org; Tue, 10 Jan 2012 05:27:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkYvT-0004jA-OH for qemu-devel@nongnu.org; Tue, 10 Jan 2012 05:27:39 -0500 Received: from anubis.se.axis.com ([195.60.68.12]:38815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkYvT-0004ir-JK for qemu-devel@nongnu.org; Tue, 10 Jan 2012 05:27:31 -0500 Received: from localhost (localhost [127.0.0.1]) by anubis.se.axis.com (Postfix) with ESMTP id 423EB19E03 for ; Tue, 10 Jan 2012 11:27:30 +0100 (CET) Received: from anubis.se.axis.com ([127.0.0.1]) by localhost (anubis.se.axis.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id CUK+03xuZE9x for ; Tue, 10 Jan 2012 11:27:29 +0100 (CET) Received: from thoth.se.axis.com (thoth.se.axis.com [10.0.2.173]) by anubis.se.axis.com (Postfix) with ESMTP id A6E0719DEF for ; Tue, 10 Jan 2012 11:27:27 +0100 (CET) Received: from localhost (edgar.se.axis.com [10.93.151.1]) by thoth.se.axis.com (Postfix) with ESMTP id 7FEAA34100 for ; Tue, 10 Jan 2012 11:27:27 +0100 (CET) From: "Edgar E. Iglesias" Date: Tue, 10 Jan 2012 11:27:24 +0100 Message-Id: <1326191247-14880-1-git-send-email-edgar.iglesias@gmail.com> Subject: [Qemu-devel] [PATCH] microblaze: Add support for the clz insn List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, edgar.iglesias@gmail.com Signed-off-by: Edgar E. Iglesias --- target-microblaze/helper.h | 1 + target-microblaze/op_helper.c | 11 +++++++++++ target-microblaze/translate.c | 11 +++++++++++ 3 files changed, 23 insertions(+), 0 deletions(-) diff --git a/target-microblaze/helper.h b/target-microblaze/helper.h index b92aa34..420ff3b 100644 --- a/target-microblaze/helper.h +++ b/target-microblaze/helper.h @@ -5,6 +5,7 @@ DEF_HELPER_0(debug, void) DEF_HELPER_FLAGS_3(carry, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32, i32, i32) DEF_HELPER_2(cmp, i32, i32, i32) DEF_HELPER_2(cmpu, i32, i32, i32) +DEF_HELPER_1(clz, i32, i32) DEF_HELPER_2(divs, i32, i32, i32) DEF_HELPER_2(divu, i32, i32, i32) diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c index 7433cec..fe38b7b 100644 --- a/target-microblaze/op_helper.c +++ b/target-microblaze/op_helper.c @@ -165,6 +165,17 @@ uint32_t helper_cmpu(uint32_t a, uint32_t b) return t; } +uint32_t helper_clz(uint32_t t0) +{ + if (t0 == 0) { + return 32; + } + if (t0 == ~0) { + return 0; + } + return clz32(t0); +} + uint32_t helper_carry(uint32_t a, uint32_t b, uint32_t cf) { uint32_t ncf; diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c index d7f513d..f4e6f30 100644 --- a/target-microblaze/translate.c +++ b/target-microblaze/translate.c @@ -809,6 +809,17 @@ static void dec_bit(DisasContext *dc) return; } break; + case 0xe0: + if ((dc->tb_flags & MSR_EE_FLAG) + && (dc->env->pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK) + && !((dc->env->pvr.regs[2] & PVR2_USE_PCMP_INSTR))) { + tcg_gen_movi_tl(cpu_SR[SR_ESR], ESR_EC_ILLEGAL_OP); + t_gen_raise_exception(dc, EXCP_HW_EXCP); + } + if (dc->env->pvr.regs[2] & PVR2_USE_PCMP_INSTR) { + gen_helper_clz(cpu_R[dc->rd], cpu_R[dc->ra]); + } + break; default: cpu_abort(dc->env, "unknown bit oc=%x op=%x rd=%d ra=%d rb=%d\n", dc->pc, op, dc->rd, dc->ra, dc->rb); -- 1.7.3.4