All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <bonzini@gnu.org>
To: Maxim Kuvyrkov <maxim@codesourcery.com>
Cc: "Maciej W. Rozycki" <macro@linux-mips.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	gcc-patches@gcc.gnu.org, linux-mips@linux-mips.org,
	rdsandiford@googlemail.com
Subject: Re: Changing the treatment of the MIPS HI and LO registers
Date: Wed, 11 Jun 2008 16:24:28 -0700	[thread overview]
Message-ID: <48505EAC.6050404@gnu.org> (raw)
In-Reply-To: <48501C55.5060602@codesourcery.com>

> GLIBC contains the following code in stdlib/longlong.h:
> <snip>
> #if defined (__mips__) && W_TYPE_SIZE == 32
> #define umul_ppmm(w1, w0, u, v) \
>   __asm__ ("multu %2,%3"                        \
>        : "=l" ((USItype) (w0)),                    \
>          "=h" ((USItype) (w1))                    \
>        : "d" ((USItype) (u)),                    \
>          "d" ((USItype) (v)))
> #define UMUL_TIME 10
> #define UDIV_TIME 100
> #endif /* __mips__ */
> </snip>

Actually, so does GCC itself.  Can you prepare a patch?

> What would be a correct fix in this case?  Something like this:
> <snip>
> #define umul_ppmm(w1, w0, u, v)                    \
>   ({unsigned int __attribute__((mode(DI))) __xx;        \
>     __xx = (unsigned int __attribute__((mode(DI)))) u * v;    \
>     w0 = __xx & ((1 << 32) - 1);                \
>     w1 = __xx >> 32;})
> </snip>
> 
> Or is there a better way?

Almost; this:

#define umul_ppmm(w1, w0, u, v)  \
   ({UDWtype __xx;       	 \
     UWtype __u = (u), __v = (v); \
     __xx = (UDWtype) __u * __v;  \
     w0 = (UWtype) __xx;          \
     w1 = __xx >> 32;})

should work.

Paolo

      parent reply	other threads:[~2008-06-11 23:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87tzgj4nh6.fsf@firetop.home>
     [not found] ` <Pine.LNX.4.55.0805272134540.18833@cliff.in.clinika.pl>
     [not found]   ` <87abib4d9t.fsf@firetop.home>
     [not found]     ` <Pine.LNX.4.55.0805272357020.18833@cliff.in.clinika.pl>
     [not found]       ` <87r6bm1ebd.fsf@firetop.home>
2008-05-29  2:01         ` Changing the treatment of the MIPS HI and LO registers Maciej W. Rozycki
     [not found]           ` <878wxtvarg.fsf@firetop.home>
2008-06-01 13:48             ` Richard Sandiford
2008-06-09 21:13               ` Richard Sandiford
2008-06-09 21:54                 ` Maciej W. Rozycki
2008-06-11 18:41                 ` Maxim Kuvyrkov
2008-06-11 18:54                   ` Richard Sandiford
2008-06-11 23:24                   ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48505EAC.6050404@gnu.org \
    --to=bonzini@gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=linux-mips@linux-mips.org \
    --cc=macro@linux-mips.org \
    --cc=maxim@codesourcery.com \
    --cc=ralf@linux-mips.org \
    --cc=rdsandiford@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.