This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR11784 - atomic __exchange_and_add() broken for ColdFire targets
- From: Bernardo Innocenti <bernie at develer dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org,libstdc++ at gcc dot gnu dot org
- Date: Tue, 5 Aug 2003 16:27:33 +0200
- Subject: Re: [PATCH] Fix PR11784 - atomic __exchange_and_add() broken for ColdFire targets
- Organization: Develer S.r.l.
- References: <200308040322.13087.bernie@develer.com> <20030804225241.GL10923@redhat.com>
On Tuesday 05 August 2003 00:52, Richard Henderson wrote:
> On Mon, Aug 04, 2003 at 03:22:13AM +0200, Bernardo Innocenti wrote:
> > +// bset with no immediate addressing
> > +#if defined(__mcf5200__) || defined(__mcf5300__)
> > + __asm__ __volatile__("1: bset.b #7,%0@\n\tjbne 1b"
> > + : /* no outputs */
> > + : "a"(&__Atomicity_lock<0>::_S_atomicity_lock)
> > + : "cc", "memory");
> > +
> > +// bset with immediate addressing
> > +#elif defined(__mc68000__)
> > + __asm__ __volatile__("1: bset.b #7,%0\n\tjbne 1b"
> > + : "=m"(__Atomicity_lock<0>::_S_atomicity_lock)
> > + : "m"(__Atomicity_lock<0>::_S_atomicity_lock)
> > + : "cc");
> > +
>
> These should be combined, surely?
No, absolutely not. ColdFire cores don't provide the immediate
addressing mode for the BSET instruction (probably because it
would make the opcode too long for the simplified execution unit).
Code generated for the second version is more efficient because
the compiler don't have to load the address into an address
register and the inline asm does not need the "clobbers memory"
constraint.
--
// Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/ http://www.develer.com/
Please don't send Word attachments - http://www.gnu.org/philosophy/no-word-attachments.html