From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W65nf-00062T-Q5 for qemu-devel@nongnu.org; Wed, 22 Jan 2014 16:57:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W65nc-0006rO-JW for qemu-devel@nongnu.org; Wed, 22 Jan 2014 16:57:31 -0500 Received: from mail-qa0-x229.google.com ([2607:f8b0:400d:c00::229]:45441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W65nc-0006rI-D4 for qemu-devel@nongnu.org; Wed, 22 Jan 2014 16:57:28 -0500 Received: by mail-qa0-f41.google.com with SMTP id w8so1239238qac.14 for ; Wed, 22 Jan 2014 13:57:27 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <52E027CF.3030105@twiddle.net> References: <52E0016D.801@redhat.com> <52E027CF.3030105@twiddle.net> Date: Wed, 22 Jan 2014 15:57:27 -0600 Message-ID: From: Xin Tong Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] Intel AVX instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: Paolo Bonzini , QEMU Developers , Stefan Hajnoczi Richard: That is very intelligient way to support AVX. I believe Bochs uses similar technique. On Wed, Jan 22, 2014 at 2:19 PM, Richard Henderson wrote: > On 01/22/2014 11:35 AM, Xin Tong wrote: >> It seems that BOCHS have AVX instructions support in interpreter. I am >> thinking an easy/reliable way to do this would be generate helper >> calls to emulate every AVX instruction and follow how BOCHS emulates >> them. Then depending on the expected frequency and difficulties, one >> can decide whether to move some of the instructions into TCG JITted >> code ? >> >> Also, it would be desirable to use the MMX/SSE structures and >> functions that already exist in QEMU target-i386/translate.c > > The way you should start is by re-using the existing SSE helpers. > > There are several things one must consider with AVX: > > (1) Old SSE insns. These do not modify bits 128 and higher. > (2) SSE insns encoded with VEX. These zero bits 128 and higher. > (3) AVX insns. These (generally) modify all 256 bits. > > Case 1 can be handled by doing nothing with the existing helpers. > > Case 2 can be handled by using the existing helper, followed by a couple of > stores to zero the high part. > > Case 3 can, with only a few exceptions, be handled by using the existing helper > twice on the two halves. Thankfully the existing helpers work with host > pointers rather than register numbers. > > That will cover at least 90% of the AVX2 instruction set. > > > r~