[LLVMdev] Proposal for atomic and synchronization instructions

Chris Lattner sabre at nondot.org
Tue Jul 10 12:01:21 PDT 2007


On Mon, 9 Jul 2007, Torvald Riegel wrote:
>>> http://www.hpl.hp.com/research/linux/atomic_ops/
>>> It already has implementations for several architectures and several
>>> compilers. It uses a different consistency model (different set of
>>> constraints for operations) and groups necessary memory barriers with
>>> instructions (helpful on some architectures). It supports a few more
>>> operations. The author (Hans Boehm) seems to also be active in the area
>>> of C/C++ memory models (or some support for this).
>>
>> LLVM doesn't emit external library calls -- there is no "-lllvm" to
>> which programs have to link, so adding an atomic operation library is
>> likely to be a non-starter. LLVM is interested in emitting instructions
>> to make atomic operations (and higher level concurrency primitives)
>> possible, which is why Chandler's work is usefully important.
>
> Please have a real look at atomic_ops first. It does have a library part to
> it -- but that's just for a nonblocking stack.
>
> All the atomic operations are macros and asm for the specific
> compiler/architecture pairs.
> So if you reuse that in the LLVM code generators, you save one large part of
> the work. Of course you can redo all this work, surely giving you a very fast
> start...

The atomic_ops library does look very interesting.  Parts of its model 
could be adapted, and the various operations seem like they would turn 
into a few inlined instructions each (not libcalls).

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list