I would like access to LLVM memory barrier instruction as a built-in from clang, which means that I need a name for it. In gcc, I see names like __builtin_ia32_mfence but those refers to X86 SSE instruction that we support. I don't see a gcc name that has the same semantics as our barrier instruction. For a name, I was thinking of __builtin_memory_barrier or __builtin_llvm_memory_barrier. Does anyone object of adding it as built-in or have a better idea for a name? -- Mon Ping
> I would like access to LLVM memory barrier instruction as a built-in > from clang, which means that I need a name for it. In gcc, I see names > like __builtin_ia32_mfence but those refers to X86 SSE instruction > that we support. I don't see a gcc name that has the same semantics > as our barrier instruction. For a name, I was thinking of > __builtin_memory_barrier or __builtin_llvm_memory_barrier. Does > anyone object of adding it as built-in or have a better idea for a name?What are the semantic differences? Thanks, Duncan.
On Tue, Sep 16, 2008 at 11:22 PM, Duncan Sands <baldrick at free.fr> wrote:>> I would like access to LLVM memory barrier instruction as a built-in >> from clang, which means that I need a name for it. In gcc, I see names >> like __builtin_ia32_mfence but those refers to X86 SSE instruction >> that we support. I don't see a gcc name that has the same semantics >> as our barrier instruction. For a name, I was thinking of >> __builtin_memory_barrier or __builtin_llvm_memory_barrier. Does >> anyone object of adding it as built-in or have a better idea for a name? > > What are the semantic differences?As far as I know, there isn't a difference, just that the intrinsic isn't platform-specific. I think SSE2 mfence is equivalent to "llvm.memory.barrier(i1 true,i1 true,i1 true,i1 true,i1 true)". -Eli
On Tue, Sep 16, 2008 at 5:42 PM, Mon Ping Wang <wangmp at apple.com> wrote:> > I would like access to LLVM memory barrier instruction as a built-in > from clang, which means that I need a name for it. In gcc, I see names > like __builtin_ia32_mfence but those refers to X86 SSE instruction > that we support. I don't see a gcc name that has the same semantics > as our barrier instruction. For a name, I was thinking of > __builtin_memory_barrier or __builtin_llvm_memory_barrier. Does > anyone object of adding it as built-in or have a better idea for a name?__sync_synchronize is the gcc builtin for a memory barrier. Andrew
Thanks for the info. My impression is that __sync_synchronize takes no arguments and is the memory barrier, i.e., "llvm.memory.barrier(i1 true,i1 true,i1 true,i1 true,i1 true)". Is that right? I would like a little finer control to express just a write barrier (st-st) or a read barrier. -- Mon Ping On Sep 17, 2008, at 5:50 AM, Andrew Lenharth wrote:> On Tue, Sep 16, 2008 at 5:42 PM, Mon Ping Wang <wangmp at apple.com> > wrote: >> >> I would like access to LLVM memory barrier instruction as a built-in >> from clang, which means that I need a name for it. In gcc, I see >> names >> like __builtin_ia32_mfence but those refers to X86 SSE instruction >> that we support. I don't see a gcc name that has the same semantics >> as our barrier instruction. For a name, I was thinking of >> __builtin_memory_barrier or __builtin_llvm_memory_barrier. Does >> anyone object of adding it as built-in or have a better idea for a >> name? > > __sync_synchronize is the gcc builtin for a memory barrier. > > Andrew > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev