Atomic ops cannot be built from C/OCaml bindings

Forgive me if I'm missing something obvious, but it seems that a
number of core instructions—I'm specifically running in to
`atomicrmw`, `fence`, and `cmpxchg` at the moment—cannot be
constructed from the C bindings, and are therefore also inaccessible
to the OCaml bindings. There are opcodes for each of these in the
llvm-c/Core.h, but there seems to be no way to construct them.

Is there a reason these should be omitted?

(I am currently running into this trying to use NVPTX, where CUDA
atomics are largely built from the native atomic instructions, in a
compiler written in OCaml.)

Thanks.

Not in particular. Things are added to the C API as needed and usually on demand.

-eric

How soon would I need to submit a patch for this for it to have a comfortable shot at making it into the 3.2 release?

LLVM 3.1 release in May. LLVM has (roughly) 6 month release cycle,
so ... :wink:

Cheers,
chenwj

In the next month or so would be good.

-eric

I finally got around to adding these.

The patch is posted in a pull request on my copy of llvm.git:

  https://github.com/jrk/llvm/pull/3

and a simple test with OCaml is here:

  https://gist.github.com/3948460

Feedback welcome.

Take two, since I didn't hear anything last time I posted about this.

I have rebased the patch onto the trunk as of a few minutes ago and am
attaching it here as a patch. I'd really like to see this go in before
3.2.

test_llvm_atom.ml is a standalone OCaml program which uses the new
interface to generate a bunch of atomic ops. It need not be included
in the repository, I'm just adding it here to help anyone who wants to
sanity check the bindings.

Thanks!

0001-Add-atomicrmw-cmpxchg-to-llvm-c-OCaml-interfaces.patch (7.96 KB)

test_llvm_atom.ml (2.45 KB)