Re: [cxx-mem-model] compare_exchange implementation II

2011-10-20 Thread Richard Henderson
On 10/19/2011 05:43 PM, Andrew MacLeod wrote: > * optabs.h (direct_optab_index): Replace DOI_atomic_compare_exchange > with DOI_atomic_compare_and_swap. > (direct_op): Add DOI_atomic_compare_and_swap. > * genopinit.c: Set atomic_compare_and_swap_optab. > * expr.h (expa

Re: [cxx-mem-model] compare_exchange implementation

2011-10-19 Thread Richard Henderson
On 10/19/2011 11:31 AM, Andrew MacLeod wrote: > If, which is more likely as I think about it, thats not the case and > the fences can look like they do in the second example (closer to the > CAS than the copies) , then the CAS can take care of both fences, > which would be much more preferable and

Re: [cxx-mem-model] compare_exchange implementation

2011-10-19 Thread Andrew MacLeod
On 10/19/2011 01:55 PM, Richard Henderson wrote: On 10/19/2011 09:26 AM, Andrew MacLeod wrote: well, they are explicitly'compare_exchange_strong' and 'compare_exchange_weak' calls... so yes, they have 'hardcoded' one or the other :-) we could alternatively do 2 separate builtins, but I

Re: [cxx-mem-model] compare_exchange implementation

2011-10-19 Thread Richard Henderson
On 10/19/2011 09:26 AM, Andrew MacLeod wrote: > well, they are explicitly'compare_exchange_strong' and > 'compare_exchange_weak' calls... so yes, they have 'hardcoded' one or the > other :-) > we could alternatively do 2 separate builtins, but I didn't see the point. > But Im ambivalent.

Fwd: Re: [cxx-mem-model] compare_exchange implementation

2011-10-19 Thread Andrew MacLeod
grr, reposting due to thunderbird apparently sneaking some HTML in and it being rejected... sigh. On 10/19/2011 11:34 AM, Richard Henderson wrote: ! weak = expand_expr (CALL_EXPR_ARG (exp, 3), NULL_RTX, ptr_mode, ! EXPAND_NORMAL); ! ! if (weak != const0_rtx&& weak !=

Re: [cxx-mem-model] compare_exchange implementation

2011-10-19 Thread Andrew MacLeod
On 10/19/2011 11:16 AM, Jakub Jelinek wrote: On Wed, Oct 19, 2011 at 08:05:26AM -0700, Richard Henderson wrote: In one of Andrew's previous ideas he split _ace into two separate builtins: T __atomic_compare_exchange (T* mem, T oldval, T newval, ...); bool __atomic_compare_exchange_success

Re: [cxx-mem-model] compare_exchange implementation

2011-10-19 Thread Richard Henderson
> ! weak = expand_expr (CALL_EXPR_ARG (exp, 3), NULL_RTX, ptr_mode, > ! EXPAND_NORMAL); > ! > ! if (weak != const0_rtx && weak != const1_rtx) > ! { > ! error ("strong/weak parameter must be 0 or 1 for > %<__atomic_compare_exchange%>"); > ! return NULL_RTX; >

Re: [cxx-mem-model] compare_exchange implementation

2011-10-19 Thread Jakub Jelinek
On Wed, Oct 19, 2011 at 08:05:26AM -0700, Richard Henderson wrote: > In one of Andrew's previous ideas he split _ace into two separate builtins: > > T __atomic_compare_exchange (T* mem, T oldval, T newval, ...); > bool __atomic_compare_exchange_success (T); > > where the input to __ace_succes

Re: [cxx-mem-model] compare_exchange implementation

2011-10-19 Thread Richard Henderson
On 10/18/2011 03:07 PM, Jakub Jelinek wrote: > On Tue, Oct 18, 2011 at 06:03:16PM -0400, Andrew MacLeod wrote: >> >> Here's the last of the missing intrinsics. compare_exchange is >> slightly different than the others since it doesn't map directly to >> an rtl pattern. Its format is : >> >> boo

Re: [cxx-mem-model] compare_exchange implementation

2011-10-19 Thread Andrew MacLeod
On 10/18/2011 06:25 PM, Andrew MacLeod wrote: Its impossible to implement a weak compare and swap unless you return both parameters in one operation. the compare_exchange matches the atomic interface for c++, and if we can't resolve it with a lock free instruction sequence, we have to leave

Re: [cxx-mem-model] compare_exchange implementation

2011-10-18 Thread Mike Stump
On Oct 18, 2011, at 3:25 PM, Andrew MacLeod wrote: > On 10/18/2011 06:07 PM, Jakub Jelinek wrote: >> On Tue, Oct 18, 2011 at 06:03:16PM -0400, Andrew MacLeod wrote: >>> Here's the last of the missing intrinsics. compare_exchange is >>> slightly different than the others since it doesn't map dire

Re: [cxx-mem-model] compare_exchange implementation

2011-10-18 Thread Andrew MacLeod
On 10/18/2011 06:07 PM, Jakub Jelinek wrote: On Tue, Oct 18, 2011 at 06:03:16PM -0400, Andrew MacLeod wrote: Here's the last of the missing intrinsics. compare_exchange is slightly different than the others since it doesn't map directly to an rtl pattern. Its format is : bool __atomic_comp

Re: [cxx-mem-model] compare_exchange implementation

2011-10-18 Thread Jakub Jelinek
On Tue, Oct 18, 2011 at 06:03:16PM -0400, Andrew MacLeod wrote: > > Here's the last of the missing intrinsics. compare_exchange is > slightly different than the others since it doesn't map directly to > an rtl pattern. Its format is : > > bool __atomic_compare_exchange (T* mem, T* expected, T