From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KvTz2-0000nv-VV for qemu-devel@nongnu.org; Thu, 30 Oct 2008 05:38:29 -0400 Received: from [199.232.76.173] (port=37641 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KvTz1-0000nn-Fx for qemu-devel@nongnu.org; Thu, 30 Oct 2008 05:38:27 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:37875) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KvTz1-0005Vo-5X for qemu-devel@nongnu.org; Thu, 30 Oct 2008 05:38:27 -0400 Message-ID: <4909808C.5040602@bellard.org> Date: Thu, 30 Oct 2008 10:38:20 +0100 From: Fabrice Bellard MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH][RFC] Run time TCGv size check for debugging References: <4908D7A3.7030309@bellard.org> <200810300007.42763.paul@codesourcery.com> In-Reply-To: <200810300007.42763.paul@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1 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: Paul Brook Cc: Blue Swirl , qemu-devel@nongnu.org Paul Brook wrote: > On Wednesday 29 October 2008, Fabrice Bellard wrote: >> Blue Swirl wrote: >>> Hi, >>> >>> When emulating a mixed 32/64 bit Qemu target CPUs it's easy to confuse >>> the TCGv size, passing 32 bit TCGv to a function expecting a 64 bit >>> one and vice versa. This patch adds a run time sanity check for TCGv >>> sizes. >>> >>> Because a 32 bit Qemu host does not really use 64 bit TCGvs, the patch >>> is only functional on a 64 bit host. Of course also a pure 32 bit Qemu >>> target is not likely to suffer from TCGv size confusion. >>> >>> Some use cases are not covered yet. Comments? >> Theses tests can be done at compile time by introducing the TCGv_i32 and >> TCGv_i64 types. The same can be done with the helpers by using a few >> macros to declare them. > > That would also require updating all the target code in translate.c to use > these types. In principle there's no reason why this couldn't be done, but > it'd be a much more invasive change. If you define TCGv as the word size of the emulated CPU, it will eliminates most of the changes. > AFAIK there's no way of doing compile time inheritance checking in C. Fabrice.