From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=48033 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q2oYA-0007op-5g for qemu-devel@nongnu.org; Thu, 24 Mar 2011 13:42:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q2oY1-0003pu-Th for qemu-devel@nongnu.org; Thu, 24 Mar 2011 13:42:15 -0400 Received: from a.mail.sonic.net ([64.142.16.245]:55941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q2oY1-0003pN-MH for qemu-devel@nongnu.org; Thu, 24 Mar 2011 13:42:13 -0400 Message-ID: <4D8B8264.7090605@twiddle.net> Date: Thu, 24 Mar 2011 10:41:56 -0700 From: Richard Henderson MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 14/17] s390x: Implement opcode helpers References: <1300982333-12802-1-git-send-email-agraf@suse.de> <1300982333-12802-15-git-send-email-agraf@suse.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Alexander Graf , Aurelien Jarno , QEMU-devel Developers On 03/24/2011 10:29 AM, Peter Maydell wrote: > On 24 March 2011 15:58, Alexander Graf wrote: > > This is more random comments in passing than a thorough review; sorry. > >> +#if HOST_LONG_BITS == 64 && defined(__GNUC__) >> + /* assuming 64-bit hosts have __uint128_t */ >> + __uint128_t dividend = (((__uint128_t)env->regs[r1]) << 64) | >> + (env->regs[r1+1]); >> + __uint128_t quotient = dividend / divisor; >> + env->regs[r1+1] = quotient; >> + __uint128_t remainder = dividend % divisor; >> + env->regs[r1] = remainder; >> +#else >> + /* 32-bit hosts would need special wrapper functionality - just abort if >> + we encounter such a case; it's very unlikely anyways. */ >> + cpu_abort(env, "128 -> 64/64 division not implemented\n"); >> +#endif > > ...I'm still using a 32 bit system :-) A couple of options: (1) Steal code from gcc's __[u]divdi3 for implementing double-word division via single-word division. In this case, your "single-word" will be long long. (2) Implement a simple bit reduction loop. This is probably easiest. (3) Reuse some of the softfloat code that manipulates 128bit quantities. This is probably the best option, particularly if the availability of __uint128 is taught to softfloat so that it doesn't always open-code stuff that the compiler could take care of. r~