From patchwork Tue Feb 19 17:40:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 221899 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 D977D2C007B for ; Wed, 20 Feb 2013 08:27:02 +1100 (EST) Received: from localhost ([::1]:56850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7riC-0000uU-Tx for incoming@patchwork.ozlabs.org; Tue, 19 Feb 2013 13:14:40 -0500 Received: from eggs.gnu.org ([208.118.235.92]:57580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7rhv-0000t2-K2 for qemu-devel@nongnu.org; Tue, 19 Feb 2013 13:14:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7rC9-00088m-MN for qemu-devel@nongnu.org; Tue, 19 Feb 2013 12:41:55 -0500 Received: from mail-pb0-f52.google.com ([209.85.160.52]:46207) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7rC9-00088e-6W for qemu-devel@nongnu.org; Tue, 19 Feb 2013 12:41:33 -0500 Received: by mail-pb0-f52.google.com with SMTP id ma3so2347012pbc.11 for ; Tue, 19 Feb 2013 09:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=T9Aie8wonLueMxvHL2CKyYpxE4VLkF2bjUUsyNf2+d8=; b=DyIggi4nd/u9+r3x2Vk8ihkxHzhQhJzYinO9OpR1kUOP7ZJoKFyOSAuuJmolToa5oH 300I7s8oZHQrptN72yokwdiqkX+eob3m2NPptRbEgyjm3JJeVG+04Eme6x2GEQmUDagF yFyIEpHlQ/giGtTApUliBfEHjGtSnBCcgo721gI6tzNULoa6GzwNvqpBaJbopuNQngdQ DzfduhmpG+D+qg0lQM/b6P9QEv+aJoNsRjPwDqT/HJ7gVmJfy82GhBXhXrh2wl67kgZb yy+NJzSkihUzrsCVbtXdB5tycN7Kv9AXdOk4y0cZ4rVysvf+CA3XI0WPmDLNzlRJUdE4 53PQ== X-Received: by 10.68.216.7 with SMTP id om7mr42042329pbc.149.1361295692503; Tue, 19 Feb 2013 09:41:32 -0800 (PST) Received: from anchor.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPS id 1sm18659295pbg.18.2013.02.19.09.41.30 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 19 Feb 2013 09:41:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Feb 2013 09:40:04 -0800 Message-Id: <1361295631-21316-31-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1361295631-21316-1-git-send-email-rth@twiddle.net> References: <1361295631-21316-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.160.52 Cc: blauwirbel@gmail.com, pbonzini@redhat.com, afaerber@suse.de, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 30/57] target-i386: use CCPrepare to generate conditional jumps 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 From: Paolo Bonzini This simplifies all the jump generation code. CCPrepare allows the code to create an efficient brcond always, so there is no need to duplicate the setcc and jcc code. Signed-off-by: Paolo Bonzini Signed-off-by: Richard Henderson --- target-i386/translate.c | 119 ++++-------------------------------------------- 1 file changed, 9 insertions(+), 110 deletions(-) diff --git a/target-i386/translate.c b/target-i386/translate.c index 046d82f..b081fc0 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -1178,117 +1178,16 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int b, TCGv reg) value 'b'. In the fast case, T0 is guaranted not to be used. */ static inline void gen_jcc1(DisasContext *s, int b, int l1) { - int inv, jcc_op, size, cond; - TCGv t0; + CCPrepare cc = gen_prepare_cc(s, b, cpu_T[0]); - inv = b & 1; - jcc_op = (b >> 1) & 7; - - switch (s->cc_op) { - /* we optimize the cmp/jcc case */ - case CC_OP_SUBB: - case CC_OP_SUBW: - case CC_OP_SUBL: - case CC_OP_SUBQ: - - size = s->cc_op - CC_OP_SUBB; - switch(jcc_op) { - case JCC_Z: - fast_jcc_z: - t0 = gen_ext_tl(cpu_tmp0, cpu_cc_dst, size, false); - tcg_gen_brcondi_tl(inv ? TCG_COND_NE : TCG_COND_EQ, t0, 0, l1); - break; - case JCC_S: - fast_jcc_s: - t0 = gen_ext_tl(cpu_tmp0, cpu_cc_dst, size, true); - tcg_gen_brcondi_tl(inv ? TCG_COND_GE : TCG_COND_LT, t0, 0, l1); - break; - - case JCC_B: - cond = inv ? TCG_COND_GEU : TCG_COND_LTU; - goto fast_jcc_b; - case JCC_BE: - cond = inv ? TCG_COND_GTU : TCG_COND_LEU; - fast_jcc_b: - tcg_gen_add_tl(cpu_tmp4, cpu_cc_dst, cpu_cc_src); - gen_extu(size, cpu_tmp4); - t0 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false); - tcg_gen_brcond_tl(cond, cpu_tmp4, t0, l1); - break; - - case JCC_L: - cond = inv ? TCG_COND_GE : TCG_COND_LT; - goto fast_jcc_l; - case JCC_LE: - cond = inv ? TCG_COND_GT : TCG_COND_LE; - fast_jcc_l: - tcg_gen_add_tl(cpu_tmp4, cpu_cc_dst, cpu_cc_src); - gen_exts(size, cpu_tmp4); - t0 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, true); - tcg_gen_brcond_tl(cond, cpu_tmp4, t0, l1); - break; - - default: - goto slow_jcc; - } - break; - - /* some jumps are easy to compute */ - case CC_OP_ADDB: - case CC_OP_ADDW: - case CC_OP_ADDL: - case CC_OP_ADDQ: - - case CC_OP_ADCB: - case CC_OP_ADCW: - case CC_OP_ADCL: - case CC_OP_ADCQ: - - case CC_OP_SBBB: - case CC_OP_SBBW: - case CC_OP_SBBL: - case CC_OP_SBBQ: - - case CC_OP_LOGICB: - case CC_OP_LOGICW: - case CC_OP_LOGICL: - case CC_OP_LOGICQ: - - case CC_OP_INCB: - case CC_OP_INCW: - case CC_OP_INCL: - case CC_OP_INCQ: - - case CC_OP_DECB: - case CC_OP_DECW: - case CC_OP_DECL: - case CC_OP_DECQ: - - case CC_OP_SHLB: - case CC_OP_SHLW: - case CC_OP_SHLL: - case CC_OP_SHLQ: - - case CC_OP_SARB: - case CC_OP_SARW: - case CC_OP_SARL: - case CC_OP_SARQ: - switch(jcc_op) { - case JCC_Z: - size = (s->cc_op - CC_OP_ADDB) & 3; - goto fast_jcc_z; - case JCC_S: - size = (s->cc_op - CC_OP_ADDB) & 3; - goto fast_jcc_s; - default: - goto slow_jcc; - } - break; - default: - slow_jcc: - gen_setcc1(s, b, cpu_T[0]); - tcg_gen_brcondi_tl(TCG_COND_NE, cpu_T[0], 0, l1); - break; + if (cc.mask != -1) { + tcg_gen_andi_tl(cpu_T[0], cc.reg, cc.mask); + cc.reg = cpu_T[0]; + } + if (cc.use_reg2) { + tcg_gen_brcond_tl(cc.cond, cc.reg, cc.reg2, l1); + } else { + tcg_gen_brcondi_tl(cc.cond, cc.reg, cc.imm, l1); } }