Reading Instructions from Ocaml

Hello,

I’m interested in the OCaml bindings, but I’ve been digging through them and it doesn’t seem possible to actually write a transformation with them. Specifically, there are a lot of functions to build each type of instruction, but there doesn’t seem to be any way to query an llvalue and determine what kind of instruction it is. Is there something that I am missing?

Thank you.

Hello,

Hello Gregory,

I'm interested in the OCaml bindings, but I've been digging through them and
it doesn't seem possible to actually write a transformation with them.
Specifically, there are a lot of functions to build each type of
instruction, but there doesn't seem to be any way to query an llvalue and
determine what kind of instruction it is. Is there something that I am
missing?

Unfortunately you'll have to write your transformations in C++. That
functionality is purposely left unexposed in order to keep the llvm-c
API stable, and allow the C++ API to evolve over time.

Hi Erick,

Are you suggesting that if I want to write my transformations in ocaml then I need to write a bitcode parser for ocaml?

It doesn’t seem like I’d have to add a whole lot to get that functionality, if I could access the class ids from ocaml and get some extra information then I could extract an ADT:

type instr =

Load of … | Store of … | …etc…
Unknown of …

What part of this wouldn’t be portable?