From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KxMpd-0005oV-Lu for qemu-devel@nongnu.org; Tue, 04 Nov 2008 09:24:33 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KxMpd-0005oC-Ae for qemu-devel@nongnu.org; Tue, 04 Nov 2008 09:24:33 -0500 Received: from [199.232.76.173] (port=47405 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KxMpd-0005o7-4D for qemu-devel@nongnu.org; Tue, 04 Nov 2008 09:24:33 -0500 Received: from mx2.redhat.com ([66.187.237.31]:50438) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KxMpc-00074j-Lv for qemu-devel@nongnu.org; Tue, 04 Nov 2008 09:24:33 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mA4EOW5P011959 for ; Tue, 4 Nov 2008 09:24:32 -0500 Message-ID: <49105B1D.6080901@redhat.com> Date: Tue, 04 Nov 2008 16:24:29 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC] TCG new op: setcond References: <761ea48b0811040215l3fa16cd6j41e7ee750602e6ea@mail.gmail.com> In-Reply-To: <761ea48b0811040215l3fa16cd6j41e7ee750602e6ea@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Laurent Desnogues wrote: > this patch implements a new TCG op, setcond, that sets a temp > to 1 if the condition is true, else to 0. The benefit is the potential > removal of brcond instructions, and helpers size reduction which > can lead to using TCG instead of helpers. > > This patch is only posted here to get comments before I dig > further into that and propose a proper update. > > One of the ARM helpers (sub with flag settings) has been > converted to TCG and uses setcond to compute carry. > > setcond has been implemented only for x86_64 TCG back-end. > > > +// TODO should apply to setcond_i64 but not tested > +static void tcg_out_setcond(TCGContext *s, int cond, > + TCGArg ret, TCGArg arg1, TCGArg arg2, int rexw) > +{ > + /* clear ret since setcc only sets the lower 8 bits */ > + tcg_out_modrm(s, 0x01 | (ARITH_XOR << 3) | rexw, ret, ret); > + /* cmp */ > + tcg_out_modrm(s, 0x01 | (ARITH_CMP << 3) | rexw, arg2, arg1); > + /* setcc */ > + // TODO this should use tcg_out_modrm > + // however currently tcg_out_modrm outputs an extra byte for [abcd]l > + //tcg_out_modrm(s, (0x90 + tcg_cond_to_jcc[cond]) | P_EXT | P_REXB, ret, 0); > + if (ret > 3) > + tcg_out8(s, 0x40); > + else if (ret > 7) > + tcg_out8(s, 0x41); > if ret == 8 this fails. You need to reverse the order of the tests. > + tcg_out8(s, 0x0f); > + tcg_out8(s, 0x90 + tcg_cond_to_jcc[cond]); > + tcg_out8(s, 0xc0 + (ret & 7)); > +} > + > > -- error compiling committee.c: too many arguments to function