Hi, The attached is the OCaml binding patch to 2.6. This still works on 2.6, because the optimizations I am working on rely on some features of 2.6, which were removed from 2.7. But from the view of OCaml bindings, it does not change too much from 2.6 to 2.7, I also merged some new bindings in 2.7 into 2.6. What this patch does are 1) bindings to define an LLVM IR pretty printer in OCaml, which traverses a LLVM AST and prints each node. To do so, it allows to access more properties of prmitive Classes: get Opcode of each instruction, get ValueID of a subclass of Value. For example, given an AllocationInst, it can return the allocation size, and other accessing methods for different kinds of Instructions. To generate names for unnamed values, the patch also makes SlotTracker visibly from ./lib/VMCore/AsmWriter.cpp to ./include/llm/Assembly/Writer.h. Such bindings are defined at ./binding/OCaml/llvm with other changes at ./lib/VMCore/Core.cpp ./include/llvm-c/Core.h 2) also more bindings to parse data layout. The existing methods in llvm::TargetData do not allow to get back contents from llvm::TargetData::Alignments. The patch adds more methods at include/llvm/Target/TargetData.h to return each element in llvm::TargetData::Alignments. These bindings are defined at ./binding/OCaml/target with other changes at ./lib/Target/Target.cpp ./include/llvm-c/Target.h 3) merged some bindings from 2.7... The patch was generated by diff -crBN ./llvm-2.6 ./llvm-2.6patch > llvm-2.6-ocamlbindings.patch where llvm-2.6patch is the upated src wrt the original code ./llvm-2.6/ To apply the patch, go to a dir that contains ./llvm-2.6, and then do patch -p0 -i llvm-2.6-ocamlbindings.patch The LLVM IR pretty printer in OCaml using those bindings just works now. But we are not sure if the bindings are safe, following code style of LLVM, or breaking other assumptions. The bindings for SlotTracker and TargetData changed the Core code in LLVM, but they are orthogonal to other bindings, so can be removed. Any input about how to improve these bindings is very helpful. Thanks. -- Jianzhou -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-2.6-ocamlbindings.patch Type: application/octet-stream Size: 89945 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100820/1a7698b2/attachment.obj>