qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 14/17] s390x: Implement opcode helpers


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH 14/17] s390x: Implement opcode helpers
Date: Thu, 24 Mar 2011 10:41:56 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9

On 03/24/2011 10:29 AM, Peter Maydell wrote:
> On 24 March 2011 15:58, Alexander Graf <address@hidden> 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~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]