From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoEHa-0003kx-Ej for qemu-devel@nongnu.org; Sat, 24 May 2014 11:54:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoEHU-0001O6-Ef for qemu-devel@nongnu.org; Sat, 24 May 2014 11:54:50 -0400 Received: from mail-pb0-x22e.google.com ([2607:f8b0:400e:c01::22e]:43300) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoEHT-0001L7-Va for qemu-devel@nongnu.org; Sat, 24 May 2014 11:54:44 -0400 Received: by mail-pb0-f46.google.com with SMTP id rq2so5553858pbb.19 for ; Sat, 24 May 2014 08:54:42 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Sat, 24 May 2014 08:53:57 -0700 Message-Id: <1400946841-21079-21-git-send-email-rth@twiddle.net> In-Reply-To: <1400946841-21079-1-git-send-email-rth@twiddle.net> References: <1400946841-21079-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PULL 20/24] tcg-mips: Simplify setcond2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Using tcg_unsigned_cond and tcg_high_cond. Also, move the function up in the file for future cleanups. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c | 95 +++++++++++++++++---------------------------------- 1 file changed, 31 insertions(+), 64 deletions(-) diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index c0a7a04..1429ec7 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -701,6 +701,37 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, tcg_out_nop(s); } +static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg al, TCGReg ah, TCGReg bl, TCGReg bh) +{ + TCGReg tmp0 = TCG_TMP0; + TCGReg tmp1 = ret; + + assert(ret != TCG_TMP0); + if (ret == ah || ret == bh) { + assert(ret != TCG_TMP1); + tmp1 = TCG_TMP1; + } + + switch (cond) { + case TCG_COND_EQ: + case TCG_COND_NE: + tcg_out_setcond(s, cond, tmp0, ah, bh); + tcg_out_setcond(s, cond, ret, al, bl); + tcg_out_opc_reg(s, (cond == TCG_COND_EQ ? OPC_AND : OPC_OR), + ret, ret, tmp0); + break; + + default: + tcg_out_setcond(s, TCG_COND_EQ, tmp0, ah, bh); + tcg_out_setcond(s, tcg_unsigned_cond(cond), tmp1, al, bl); + tcg_out_opc_reg(s, OPC_AND, tmp1, tmp1, tmp0); + tcg_out_setcond(s, tcg_high_cond(cond), tmp0, ah, bh); + tcg_out_opc_reg(s, OPC_OR, ret, tmp1, tmp0); + break; + } +} + /* XXX: we implement it at the target level to avoid having to handle cross basic blocks temporaries */ static void tcg_out_brcond2(TCGContext *s, TCGCond cond, TCGArg arg1, @@ -829,70 +860,6 @@ static void tcg_out_movcond(TCGContext *s, TCGCond cond, TCGReg ret, } } -/* XXX: we implement it at the target level to avoid having to - handle cross basic blocks temporaries */ -static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret, - TCGArg arg1, TCGArg arg2, TCGArg arg3, TCGArg arg4) -{ - switch (cond) { - case TCG_COND_EQ: - tcg_out_setcond(s, TCG_COND_EQ, TCG_TMP0, arg2, arg4); - tcg_out_setcond(s, TCG_COND_EQ, TCG_TMP1, arg1, arg3); - tcg_out_opc_reg(s, OPC_AND, ret, TCG_TMP0, TCG_TMP1); - return; - case TCG_COND_NE: - tcg_out_setcond(s, TCG_COND_NE, TCG_TMP0, arg2, arg4); - tcg_out_setcond(s, TCG_COND_NE, TCG_TMP1, arg1, arg3); - tcg_out_opc_reg(s, OPC_OR, ret, TCG_TMP0, TCG_TMP1); - return; - case TCG_COND_LT: - case TCG_COND_LE: - tcg_out_setcond(s, TCG_COND_LT, TCG_TMP0, arg2, arg4); - break; - case TCG_COND_GT: - case TCG_COND_GE: - tcg_out_setcond(s, TCG_COND_GT, TCG_TMP0, arg2, arg4); - break; - case TCG_COND_LTU: - case TCG_COND_LEU: - tcg_out_setcond(s, TCG_COND_LTU, TCG_TMP0, arg2, arg4); - break; - case TCG_COND_GTU: - case TCG_COND_GEU: - tcg_out_setcond(s, TCG_COND_GTU, TCG_TMP0, arg2, arg4); - break; - default: - tcg_abort(); - break; - } - - tcg_out_setcond(s, TCG_COND_EQ, TCG_TMP1, arg2, arg4); - - switch(cond) { - case TCG_COND_LT: - case TCG_COND_LTU: - tcg_out_setcond(s, TCG_COND_LTU, ret, arg1, arg3); - break; - case TCG_COND_LE: - case TCG_COND_LEU: - tcg_out_setcond(s, TCG_COND_LEU, ret, arg1, arg3); - break; - case TCG_COND_GT: - case TCG_COND_GTU: - tcg_out_setcond(s, TCG_COND_GTU, ret, arg1, arg3); - break; - case TCG_COND_GE: - case TCG_COND_GEU: - tcg_out_setcond(s, TCG_COND_GEU, ret, arg1, arg3); - break; - default: - tcg_abort(); - } - - tcg_out_opc_reg(s, OPC_AND, ret, ret, TCG_TMP1); - tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_TMP0); -} - static void tcg_out_call_int(TCGContext *s, tcg_insn_unit *arg, bool tail) { /* Note that the ABI requires the called function's address to be -- 1.9.0