From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKk7b-0003RJ-6H for qemu-devel@nongnu.org; Sat, 14 Sep 2013 03:18:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKk7V-0004UR-Gv for qemu-devel@nongnu.org; Sat, 14 Sep 2013 03:18:23 -0400 Received: from [2a03:4000:1::4e2f:c7ac:d] (port=40239 helo=v220110690675601.yourvserver.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKk7V-0004TP-51 for qemu-devel@nongnu.org; Sat, 14 Sep 2013 03:18:17 -0400 Message-ID: <52340DAA.1070807@weilnetz.de> Date: Sat, 14 Sep 2013 09:18:02 +0200 From: Stefan Weil MIME-Version: 1.0 References: <1379015124-21055-1-git-send-email-sw@weilnetz.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] tci: Detect function argument alignment List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel , Richard Henderson Am 12.09.2013 22:35, schrieb Peter Maydell: > On 12 September 2013 20:45, Stefan Weil wrote: >> +else >> + >> + # Cross compilation, so we cannot launch a program. Require configure argument. >> + error_exit "Unknown function argument alignment" \ >> + "The TCG interpreter must know the alignment of function arguments." \ >> + "Configure cannot determine the alignment because this is a cross build," \ >> + "so please add --enable-call-align-args or --disable-call-align-args." >> + >> +fi > No new configure tests which can't cope with cross compilation, > please. I generally agree (and still hope that the endianness patch will be committed soon). For the calling convention test I don't see an alternative, see my remarks below. > >> +#if defined(CONFIG_CALL_ALIGN_ARGS) >> +# define TCG_TARGET_CALL_ALIGN_ARGS 1 >> +#endif > You're not a native assembly backend, you can't rely on this > to be sufficient. Use libffi or call the target function with > the exact correct prototype. > > -- PMM I had a look on libffi now and don't see how it could solve my problem. As far as I could see, libffi must be ported to new architectures, so its use would restrict the portability of TCI. Calling the helper function with the correct prototype seems to be the solution with the best portability and would also make TCI a little bit faster. There is a drawback of that solution: it needs modifications in the TCG opcode generation which would no longer be identical to all other TCG targets (or I'd have to search the given address of the helper function in a lookup table which would cost too much time). Therefore I'd like to implement that solution as a configure time option: either TCI calls helpers with the correct prototype, or it uses the macros TCG_TARGET_CALL_ALIGN_ARGS and TCG_TARGET_EXTEND_ARGS. This means that we still need some way to determine the call alignment and whether 32 bit arguments are extended to 64 bit values on 64 bit hosts for the solution with unmodified TCG opcode generator. Any test for this requires native compilation. Of course I can add the known values for the common architectures, so these architectures would not require the test. Then only cross compilation for exotic architectures would require an explicit configure option which defines argument alignment and extension. Regards Stefan