From patchwork Wed Mar 6 22:00:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 225667 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 B1E1E2C029D for ; Thu, 7 Mar 2013 09:05:40 +1100 (EST) Received: from localhost ([::1]:47061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDMSw-0003es-TN for incoming@patchwork.ozlabs.org; Wed, 06 Mar 2013 17:05:38 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDMOy-00055G-7p for qemu-devel@nongnu.org; Wed, 06 Mar 2013 17:01:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDMOw-0004kx-OG for qemu-devel@nongnu.org; Wed, 06 Mar 2013 17:01:32 -0500 Received: from ssl.serverraum.org ([88.198.40.39]:47196) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDMOw-0004kj-Fp for qemu-devel@nongnu.org; Wed, 06 Mar 2013 17:01:30 -0500 Received: from localhost (localhost [127.0.0.1]) by ssl.serverraum.org (Postfix) with ESMTP id 43C6B3F05B; Wed, 6 Mar 2013 23:00:45 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail.serverraum.org Received: from ssl.serverraum.org ([127.0.0.1]) by localhost (web.serverraum.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ns4vCOyHJIck; Wed, 6 Mar 2013 23:00:45 +0100 (CET) Received: from thanatos.fritz.box (95-89-88-22-dynip.superkabel.de [95.89.88.22]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 05AD43F051; Wed, 6 Mar 2013 23:00:44 +0100 (CET) From: Michael Walle To: qemu-devel@nongnu.org Date: Wed, 6 Mar 2013 23:00:04 +0100 Message-Id: <1362607209-12232-8-git-send-email-michael@walle.cc> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1362607209-12232-1-git-send-email-michael@walle.cc> References: <1362607209-12232-1-git-send-email-michael@walle.cc> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 88.198.40.39 Cc: Michael Walle Subject: [Qemu-devel] [PATCH 07/12] target-lm32: fix cmpgui and cmpgeui opcodes 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 For unsigned compares the immediate has to be zero extended. Signed-off-by: Michael Walle --- target-lm32/translate.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/target-lm32/translate.c b/target-lm32/translate.c index f51ffc5..e885bb3 100644 --- a/target-lm32/translate.c +++ b/target-lm32/translate.c @@ -324,10 +324,20 @@ static inline void gen_compare(DisasContext *dc, int cond) int rX = (dc->format == OP_FMT_RR) ? dc->r2 : dc->r1; int rY = (dc->format == OP_FMT_RR) ? dc->r0 : dc->r0; int rZ = (dc->format == OP_FMT_RR) ? dc->r1 : -1; + int i; if (dc->format == OP_FMT_RI) { - tcg_gen_setcondi_tl(cond, cpu_R[rX], cpu_R[rY], - sign_extend(dc->imm16, 16)); + switch (cond) { + case TCG_COND_GEU: + case TCG_COND_GTU: + i = zero_extend(dc->imm16, 16); + break; + default: + i = sign_extend(dc->imm16, 16); + break; + } + + tcg_gen_setcondi_tl(cond, cpu_R[rX], cpu_R[rY], i); } else { tcg_gen_setcond_tl(cond, cpu_R[rX], cpu_R[rY], cpu_R[rZ]); } @@ -373,7 +383,7 @@ static void dec_cmpgeu(DisasContext *dc) { if (dc->format == OP_FMT_RI) { LOG_DIS("cmpgeui r%d, r%d, %d\n", dc->r0, dc->r1, - sign_extend(dc->imm16, 16)); + zero_extend(dc->imm16, 16)); } else { LOG_DIS("cmpgeu r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1); } @@ -385,7 +395,7 @@ static void dec_cmpgu(DisasContext *dc) { if (dc->format == OP_FMT_RI) { LOG_DIS("cmpgui r%d, r%d, %d\n", dc->r0, dc->r1, - sign_extend(dc->imm16, 16)); + zero_extend(dc->imm16, 16)); } else { LOG_DIS("cmpgu r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1); }