From patchwork Sat Apr 13 12:47:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 236335 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D2E972C009C for ; Sat, 13 Apr 2013 22:48:38 +1000 (EST) Received: from localhost ([::1]:34184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQzsj-0003ZW-1q for incoming@patchwork.ozlabs.org; Sat, 13 Apr 2013 08:48:37 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQzro-0002ua-SU for qemu-devel@nongnu.org; Sat, 13 Apr 2013 08:47:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQzrl-0005So-I1 for qemu-devel@nongnu.org; Sat, 13 Apr 2013 08:47:40 -0400 Received: from hall.aurel32.net ([2001:470:1f15:c4f::1]:40478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQzrl-0005Rz-9L for qemu-devel@nongnu.org; Sat, 13 Apr 2013 08:47:37 -0400 Received: from [2001:470:d4ed:0:ea11:32ff:fea1:831a] (helo=ohm.aurel32.net) by hall.aurel32.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UQzrj-000282-Ji; Sat, 13 Apr 2013 14:47:35 +0200 Received: from aurel32 by ohm.aurel32.net with local (Exim 4.80) (envelope-from ) id 1UQzrh-0007Mb-QW; Sat, 13 Apr 2013 14:47:33 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Sat, 13 Apr 2013 14:47:25 +0200 Message-Id: <1365857251-28173-5-git-send-email-aurelien@aurel32.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1365857251-28173-1-git-send-email-aurelien@aurel32.net> References: <1365857251-28173-1-git-send-email-aurelien@aurel32.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:470:1f15:c4f::1 Cc: qemu-ppc@nongnu.org, Alexander Graf , Aurelien Jarno Subject: [Qemu-devel] [PATCH 04/10] target-ppc: emulate cmpb instruction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Needed for Power ISA version 2.05 compliance. Cc: Alexander Graf Signed-off-by: Aurelien Jarno Reviewed-by: Richard Henderson --- target-ppc/helper.h | 1 + target-ppc/int_helper.c | 15 +++++++++++++++ target-ppc/translate.c | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/target-ppc/helper.h b/target-ppc/helper.h index 07397b2..56814b5 100644 --- a/target-ppc/helper.h +++ b/target-ppc/helper.h @@ -36,6 +36,7 @@ DEF_HELPER_3(mulldo, i64, env, i64, i64) DEF_HELPER_FLAGS_1(cntlzw, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_1(popcntb, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_1(popcntw, TCG_CALL_NO_RWG_SE, tl, tl) +DEF_HELPER_FLAGS_2(cmpb, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_3(sraw, tl, env, tl, tl) #if defined(TARGET_PPC64) DEF_HELPER_FLAGS_1(cntlzd, TCG_CALL_NO_RWG_SE, tl, tl) diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c index 54eca9b..e50bdd2 100644 --- a/target-ppc/int_helper.c +++ b/target-ppc/int_helper.c @@ -53,6 +53,21 @@ target_ulong helper_cntlzd(target_ulong t) } #endif +target_ulong helper_cmpb(target_ulong rs, target_ulong rb) +{ + target_ulong mask = 0xff; + target_ulong ra = 0; + int i; + + for (i = 0; i < sizeof(target_ulong); i++) { + if ((rs & mask) == (rb & mask)) { + ra |= mask; + } + mask <<= 8; + } + return ra; +} + /* shift right arithmetic helper */ target_ulong helper_sraw(CPUPPCState *env, target_ulong value, target_ulong shift) diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 68cd1c5..80b7111 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -739,6 +739,13 @@ static void gen_isel(DisasContext *ctx) tcg_temp_free_i32(t0); } +/* cmpb: PowerPC 2.05 specification */ +static void gen_cmpb(DisasContext *ctx) +{ + gen_helper_cmpb(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], + cpu_gpr[rB(ctx->opcode)]); +} + /*** Integer arithmetic ***/ static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0, @@ -8454,6 +8461,7 @@ GEN_HANDLER(cmp, 0x1F, 0x00, 0x00, 0x00400000, PPC_INTEGER), GEN_HANDLER(cmpi, 0x0B, 0xFF, 0xFF, 0x00400000, PPC_INTEGER), GEN_HANDLER(cmpl, 0x1F, 0x00, 0x01, 0x00400000, PPC_INTEGER), GEN_HANDLER(cmpli, 0x0A, 0xFF, 0xFF, 0x00400000, PPC_INTEGER), +GEN_HANDLER_E(cmpb, 0x1F, 0x1C, 0x0F, 0x00000001, PPC_NONE, PPC2_ISA205), GEN_HANDLER(isel, 0x1F, 0x0F, 0xFF, 0x00000001, PPC_ISEL), GEN_HANDLER(addi, 0x0E, 0xFF, 0xFF, 0x00000000, PPC_INTEGER), GEN_HANDLER(addic, 0x0C, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),