public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* About machine description for atomic_exchange
@ 2019-09-09 20:41 William Tambe
  2019-09-10  9:18 ` Oleg Endo
  0 siblings, 1 reply; 4+ messages in thread
From: William Tambe @ 2019-09-09 20:41 UTC (permalink / raw)
  To: gcc-help

I use documentation for atomic_exchange from:
https://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html#Standard-Names

When defining machine description for atomic_exchange, I find that GCC
mark operands[1] as volatile such that (MEM_VOLATILE_P (operands[1]))
returns TRUE; even when the memory operand is not declared using the C
keyword "volatile".

Is there a way to have atomic_exchange not marking operands[1] as
volatile unless the memory operand was declared volatile ?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: About machine description for atomic_exchange
  2019-09-09 20:41 About machine description for atomic_exchange William Tambe
@ 2019-09-10  9:18 ` Oleg Endo
  2019-09-12 15:04   ` William Tambe
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Endo @ 2019-09-10  9:18 UTC (permalink / raw)
  To: William Tambe, gcc-help

On Mon, 2019-09-09 at 15:40 -0500, William Tambe wrote:
> I use documentation for atomic_exchange from:
> https://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html#Standard-Names
> 
> When defining machine description for atomic_exchange, I find that GCC
> mark operands[1] as volatile such that (MEM_VOLATILE_P (operands[1]))
> returns TRUE; even when the memory operand is not declared using the C
> keyword "volatile".
> 
> Is there a way to have atomic_exchange not marking operands[1] as
> volatile unless the memory operand was declared volatile ?

If you want to distinguish that, one way is to implement all atomic
patterns in the backedn.  Then you know that those come from
__atomic__... calls.  In the other patterns, you can then assume that
MEM_VOLATILE_P must be a mem ref for everything else (that is
considered a volatile mem ref).

Cheers,
Oleg

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: About machine description for atomic_exchange
  2019-09-10  9:18 ` Oleg Endo
@ 2019-09-12 15:04   ` William Tambe
  2019-09-13  8:15     ` Andrew Haley
  0 siblings, 1 reply; 4+ messages in thread
From: William Tambe @ 2019-09-12 15:04 UTC (permalink / raw)
  To: Oleg Endo; +Cc: gcc-help

Is there an example, not necessarily for atomic_exchange, that I can follow ?

Also, is this behavior related to GCC memory model ? ie:
(MEM_VOLATILE_P (operands[1])) for atomic_exchange always TRUE
regardless of whether the memory operand was declared using
"volatile".

On Tue, Sep 10, 2019 at 4:18 AM Oleg Endo <oleg.endo@t-online.de> wrote:
>
> On Mon, 2019-09-09 at 15:40 -0500, William Tambe wrote:
> > I use documentation for atomic_exchange from:
> > https://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html#Standard-Names
> >
> > When defining machine description for atomic_exchange, I find that GCC
> > mark operands[1] as volatile such that (MEM_VOLATILE_P (operands[1]))
> > returns TRUE; even when the memory operand is not declared using the C
> > keyword "volatile".
> >
> > Is there a way to have atomic_exchange not marking operands[1] as
> > volatile unless the memory operand was declared volatile ?
>
> If you want to distinguish that, one way is to implement all atomic
> patterns in the backedn.  Then you know that those come from
> __atomic__... calls.  In the other patterns, you can then assume that
> MEM_VOLATILE_P must be a mem ref for everything else (that is
> considered a volatile mem ref).
>
> Cheers,
> Oleg
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: About machine description for atomic_exchange
  2019-09-12 15:04   ` William Tambe
@ 2019-09-13  8:15     ` Andrew Haley
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Haley @ 2019-09-13  8:15 UTC (permalink / raw)
  To: William Tambe, Oleg Endo; +Cc: gcc-help

On 9/12/19 4:04 PM, William Tambe wrote:
> Is there an example, not necessarily for atomic_exchange, that I can follow ?
> 
> Also, is this behavior related to GCC memory model ? ie:
> (MEM_VOLATILE_P (operands[1])) for atomic_exchange always TRUE
> regardless of whether the memory operand was declared using
> "volatile"

I've been thinking about this, and have been unable to come up with a
use for a non-volatile atomic_exchange. If you had such a thing you'd
also have undefined behaviour if an other thread accessed the operand
racily.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-13  8:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09 20:41 About machine description for atomic_exchange William Tambe
2019-09-10  9:18 ` Oleg Endo
2019-09-12 15:04   ` William Tambe
2019-09-13  8:15     ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).