Received: from [140.186.70.92] (port=60287 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pc5Qk-0003kl-SX for qemu-devel@nongnu.org; Sun, 09 Jan 2011 19:16:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pc5Qi-00047V-EZ for qemu-devel@nongnu.org; Sun, 09 Jan 2011 19:16:14 -0500 Received: from hall.aurel32.net ([88.191.126.93]:55830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pc5Qi-00047E-A3 for qemu-devel@nongnu.org; Sun, 09 Jan 2011 19:16:12 -0500 Date: Mon, 10 Jan 2011 01:16:10 +0100 From: Aurelien Jarno Subject: Re: [Qemu-devel] Re: [PATCH 5/7] tcg-i386: Implement deposit operation. Message-ID: <20110110001610.GB17026@hall.aurel32.net> References: <1294440183-885-1-git-send-email-rth@twiddle.net> <1294440183-885-6-git-send-email-rth@twiddle.net> <20110109215335.GA21189@volta.aurel32.net> <4D2A3CD1.2050003@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <4D2A3CD1.2050003@twiddle.net> Sender: Aurelien Jarno List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org, Alexander Graf On Sun, Jan 09, 2011 at 02:55:13PM -0800, Richard Henderson wrote: > On 01/09/2011 01:53 PM, Aurelien Jarno wrote: > >> + if (inout == val) { > >> + TCGType type = rexw ? TCG_TYPE_I64 : TCG_TYPE_I32; > >> + TCGRegSet inuse = s->reserved_regs; > >> + > >> + tcg_regset_set_reg(inuse, inout); > >> + val = tcg_reg_alloc(s, tcg_target_available_regs[type], inuse); > >> + > >> + tcg_out_mov(s, type, val, inout); > > > > I am a bit worried by allocating a new register here, especially on the > > i386 target, where the number of free registers is quite low, and often > > 0. We already had to tweak some code to avoid calls to tcg_abort() due > > to missing registers. > > Well, as I said, this case can't actually trigger due to a bug in the > register allocator. This can be seen in an insn like > > mov %dl,%dh > > where you would expect to see > > deposit x,x,x,8,8 > > however, the matching constraint forces the destination and the matching > source into a new register: > > /* if the input is aliased to an output and if it is > not dead after the instruction, we must allocate > a new register and move it */ > if (!IS_DEAD_IARG(i - nb_oargs)) > goto allocate_in_reg; I guess we should also add a case when the input argument and the output argument are the same. > which means that we'll always see > > mov y,x > deposit y,y,x,8,8 > > So I could simply put a tcg_abort there. It would be up to whoever > improves the register allocator to provide some mechanism for a > backend to allocate a scratch. What do you think? > The code being written now or latter doesn't change the question to know if it is always possible to allocate one scratch register here on i386. Up to know we didn't provide any function for allocating a scratch register, as on CISC CPU the op directly match to an instruction whereas on RISC CPUs where the op has to be emulated with multiple instructions, they are enough registers available to define one or more permanent scratch register. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net