summaryrefslogtreecommitdiff
path: root/bindings
AgeCommit message (Collapse)AuthorFilesLines
2015-01-13[OCaml] Use $CAMLORIGIN, an rpath-$ORIGIN-like mechanism in OCaml.Peter Zotov1-4/+10
As a result, installations of LLVM in non-standard locations will not require passing custom -ccopt -L flags when building the binary, nor absolute paths would be embedded in the cma/cmxa files. Additionally, the executables will not require changes to LD_LIBRARY_PATH, although CAML_LD_LIBRARY_PATH still has to be set for ocamlc without -custom. See http://caml.inria.fr/mantis/view.php?id=6642. Note that the patch is approved, but not merged yet. It will be released in 4.03 and likely 4.02. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225778 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-30[OCaml] [cmake] Use LLVM_LIBRARY_DIR instead of LLVM_LIBRARY_OUTPUT_INTDIR.Peter Zotov2-4/+4
The latter variable is internal. Original patch by Ramkumar Ramachandra <artagnon@gmail.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224977 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-24[OCaml] Expose Llvm_executionengine.get_{global_value,function}_address.Peter Zotov3-15/+40
Patch by Ramkumar Ramachandra <artagnon@gmail.com>. Also remove Llvm_executionengine.get_pointer_to_global, as it is actually deprecated and didn't appear in a stable release. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224801 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-23Finish removing DestroySource.Rafael Espindola4-27/+7
Fixes pr21901. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224782 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-23[OCaml] PR22014: OCaml bindings didn't link to libLLVM-*.so with -Wl,--as-neededPeter Zotov1-2/+2
Patch by Evangelos Foutras <evangelos@foutrelis.com>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224766 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-13Go bindings: introduce Value.ConstantAsMetadata.Peter Collingbourne3-0/+10
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224179 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-13Go bindings: introduce llvm.TemporaryMDNode.Peter Collingbourne3-0/+13
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224178 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-13Go bindings: introduce Metadata.ReplaceAllUsesWith.Peter Collingbourne3-0/+16
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224177 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-13Go bindings: expose the Metadata type.Peter Collingbourne6-266/+338
Also modifies SetCurrentDebugLocation to take individual arguments rather than an MDNode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224176 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-13Go bindings: remove contextless metadata bindings.Peter Collingbourne1-11/+0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224175 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09IR: Split Metadata from ValueDuncan P. N. Exon Smith1-24/+41
Split `Metadata` away from the `Value` class hierarchy, as part of PR21532. Assembly and bitcode changes are in the wings, but this is the bulk of the change for the IR C++ API. I have a follow-up patch prepared for `clang`. If this breaks other sub-projects, I apologize in advance :(. Help me compile it on Darwin I'll try to fix it. FWIW, the errors should be easy to fix, so it may be simpler to just fix it yourself. This breaks the build for all metadata-related code that's out-of-tree. Rest assured the transition is mechanical and the compiler should catch almost all of the problems. Here's a quick guide for updating your code: - `Metadata` is the root of a class hierarchy with three main classes: `MDNode`, `MDString`, and `ValueAsMetadata`. It is distinct from the `Value` class hierarchy. It is typeless -- i.e., instances do *not* have a `Type`. - `MDNode`'s operands are all `Metadata *` (instead of `Value *`). - `TrackingVH<MDNode>` and `WeakVH` referring to metadata can be replaced with `TrackingMDNodeRef` and `TrackingMDRef`, respectively. If you're referring solely to resolved `MDNode`s -- post graph construction -- just use `MDNode*`. - `MDNode` (and the rest of `Metadata`) have only limited support for `replaceAllUsesWith()`. As long as an `MDNode` is pointing at a forward declaration -- the result of `MDNode::getTemporary()` -- it maintains a side map of its uses and can RAUW itself. Once the forward declarations are fully resolved RAUW support is dropped on the ground. This means that uniquing collisions on changing operands cause nodes to become "distinct". (This already happened fairly commonly, whenever an operand went to null.) If you're constructing complex (non self-reference) `MDNode` cycles, you need to call `MDNode::resolveCycles()` on each node (or on a top-level node that somehow references all of the nodes). Also, don't do that. Metadata cycles (and the RAUW machinery needed to construct them) are expensive. - An `MDNode` can only refer to a `Constant` through a bridge called `ConstantAsMetadata` (one of the subclasses of `ValueAsMetadata`). As a side effect, accessing an operand of an `MDNode` that is known to be, e.g., `ConstantInt`, takes three steps: first, cast from `Metadata` to `ConstantAsMetadata`; second, extract the `Constant`; third, cast down to `ConstantInt`. The eventual goal is to introduce `MDInt`/`MDFloat`/etc. and have metadata schema owners transition away from using `Constant`s when the type isn't important (and they don't care about referring to `GlobalValue`s). In the meantime, I've added transitional API to the `mdconst` namespace that matches semantics with the old code, in order to avoid adding the error-prone three-step equivalent to every call site. If your old code was: MDNode *N = foo(); bar(isa <ConstantInt>(N->getOperand(0))); baz(cast <ConstantInt>(N->getOperand(1))); bak(cast_or_null <ConstantInt>(N->getOperand(2))); bat(dyn_cast <ConstantInt>(N->getOperand(3))); bay(dyn_cast_or_null<ConstantInt>(N->getOperand(4))); you can trivially match its semantics with: MDNode *N = foo(); bar(mdconst::hasa <ConstantInt>(N->getOperand(0))); baz(mdconst::extract <ConstantInt>(N->getOperand(1))); bak(mdconst::extract_or_null <ConstantInt>(N->getOperand(2))); bat(mdconst::dyn_extract <ConstantInt>(N->getOperand(3))); bay(mdconst::dyn_extract_or_null<ConstantInt>(N->getOperand(4))); and when you transition your metadata schema to `MDInt`: MDNode *N = foo(); bar(isa <MDInt>(N->getOperand(0))); baz(cast <MDInt>(N->getOperand(1))); bak(cast_or_null <MDInt>(N->getOperand(2))); bat(dyn_cast <MDInt>(N->getOperand(3))); bay(dyn_cast_or_null<MDInt>(N->getOperand(4))); - A `CallInst` -- specifically, intrinsic instructions -- can refer to metadata through a bridge called `MetadataAsValue`. This is a subclass of `Value` where `getType()->isMetadataTy()`. `MetadataAsValue` is the *only* class that can legally refer to a `LocalAsMetadata`, which is a bridged form of non-`Constant` values like `Argument` and `Instruction`. It can also refer to any other `Metadata` subclass. (I'll break all your testcases in a follow-up commit, when I propagate this change to assembly.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223802 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-02Add bindings for the rest of the MCJIT options that we previouslyEric Christopher2-0/+15
had support for. We're still missing a binding for an MCJIT memory manager. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223153 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-02[OCaml] Add Llvm.mdnull.Peter Zotov3-0/+9
Patch by Gideon Smeding <gideon.smeding@3ds.com>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223129 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-01[OCaml] Move Llvm.clone_module to its own Llvm_transform_utils module.Peter Zotov12-7/+94
This way most code won't link this (substantially large) library, if compiled statically with LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223072 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-01[OCaml] [cmake] Add CMake buildsystem for OCaml.Peter Zotov16-0/+114
Closes PR15325. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223071 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26Reformat with gofmt.Eric Christopher1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222806 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26Make SetMCJITOptimizationLevel more of a method and pass optionsEric Christopher2-5/+5
as a reference. Move closer to the type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222805 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26Make sure that the go bindings call LLVMInitializeMCJITCompilerOptionsEric Christopher2-12/+16
so that they initialize the code generation model to the correct (non-zero) default model. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222804 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25Go bindings: add DIBuilder.InsertValueAtEndPeter Collingbourne3-2/+27
Expose llvm::DIBuilder::insertDbgValueIntrinsic as DIBuilder.InsertValueAtEnd in the Go bindings, to support attaching debug metadata to register values. Patch by Andrew Wilkins! Differential Revision: http://reviews.llvm.org/D6374 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222790 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19Expose LLVM version string via macro in llvm-config.h, and modify Go bindingsPeter Collingbourne2-4/+19
to make use of it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222307 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[OCaml] Fix mismatched CAMLparam/CAMLreturn.Peter Zotov1-4/+3
Also, revert r221142--it was an incorrect fix to this bug which fixed tests by accident. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221149 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[OCaml] Add -g on DEBUG_SYMBOLS=1, not ENABLE_OPTIMIZED.Peter Zotov1-1/+1
Thanks echristo for pointing this out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221145 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[OCaml] Don't use deprecated non-caml_namespaced functions.Peter Zotov1-7/+7
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221143 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[OCaml] Initialize local roots prior to raising.Peter Zotov1-3/+4
On 4.02, the OCaml unwinder otherwise gets confused and segfaults. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221142 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[OCaml] Core package should depend on LLVMTransformUtils for LLVMCloneModule.Peter Zotov1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221141 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[OCaml] Fix ocamlc -custom builds when configured as --enable-shared.Peter Zotov1-2/+3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221140 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[OCaml] Avoid embedding absolute paths into executables.Peter Zotov1-14/+14
Bindings built out-of-tree, e.g. via OPAM, should append a line to META.llvm like the following: linkopts = "-cclib -L$libdir -cclib -Wl,-rpath,$libdir" where $libdir is the lib/ directory where LLVM libraries are installed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221139 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[OCaml] Don't build stub libraries twice.Peter Zotov1-0/+3
The default Makefile.rules BUILD_ARCHIVE machinery was unintentionally enabled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221138 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[OCaml] META: remove exists_if(toplevel).Peter Zotov2-2/+0
ocamlfind ignores the predicates in this case, making the package unavailable for batch compilation as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221136 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-03[OCaml] ExecutionEngine package should not depend on interpreter.Peter Zotov1-1/+1
Interpreter support was removed in r220957. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221135 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-31[OCaml] Ensure consistent naming.Peter Zotov6-3/+3
Specifically: * Directories match module names. * Test names match module names. * The language is called "OCaml", not "Ocaml". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220958 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-31[OCaml] Rework Llvm_executionengine using ctypes.Peter Zotov6-527/+145
Since JIT->MCJIT migration, most of the ExecutionEngine interface became deprecated and/or broken. This especially affected the OCaml bindings, as runFunction is no longer available, and unlike in C, it is not possible to coerce a pointer to a function and call it in OCaml. In practice, LLVM 3.5 shipped completely unusable Llvm_executionengine. The GenericValue interface and runFunction were essentially a poor man's FFI. As such, this interface was removed and instead a dependency on ctypes >=0.3 added, which handled platform-specific aspects of accessing data and calling functions. The new interface does not expose JIT (which is a shim around MCJIT), as well as the interpreter (which can't handle a lot of valid IR). Llvm_executionengine.add_global_mapping is currently unusable due to PR20656. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220957 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-30[OCaml] Expose LLVMCloneModule.Peter Zotov2-0/+4
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220903 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-30[OCaml] Expose LLVM{Get,Set}DLLStorageClass.Peter Zotov3-0/+37
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220902 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-30[OCaml] [autoconf] Migrate to ocamlfind.Peter Zotov1-46/+18
This commit updates the OCaml bindings and tests to use ocamlfind. The bindings are migrated in order to use ctypes, which are now required for MCJIT-backed Llvm_executionengine. The tests are migrated in order to use OUnit and to verify that the distributed META.llvm allows to build working executables. Every OCaml toolchain invocation is now chained through ocamlfind, which (in theory) allows to cross-compile the OCaml bindings. The configure script now checks for ctypes (>= 0.2.3) and OUnit (>= 2). The code depending on these libraries will be added later. The configure script does not check the package versions in order to keep changes less invasive. Additionally, OCaml bindings will now be automatically enabled if ocamlfind is detected on the system, rather than ocamlc, as it was before. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220899 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-30[OCaml] De-duplicate llvm_raise and llvm_string_of_message.Peter Zotov7-71/+14
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220898 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-29[OCaml] Expose Llvm.parse_command_line_options.Peter Zotov3-0/+21
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220847 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-29[OCaml] Expose Llvm_target.TargetMachine.add_analysis_passes.Peter Zotov3-0/+13
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220846 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-29[OCaml] If compiled without --enable-shared, hide packages from toplevel.Peter Zotov2-0/+2
Pretend they do not exist using exists_if. This is better than the current situation, which is the error: Error: The external function `llvm_global_succ' is not available but still somewhat confusing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220845 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-29[OCaml] Expose Llvm_bitwriter.write_bitcode_to_memory_buffer.Peter Zotov3-13/+28
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220844 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-29[OCaml] Drop support for 3.12.1 and earlier.Peter Zotov28-262/+166
In practice this means: * Always using -g flag. * Embedding -cclib -lstdc++ into the corresponding cma/cmxa file. This also moves -lstdc++ in a single place. * Using caml_named_value instead of a homegrown mechanism. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220843 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-29[OCaml] Synchronize transformations with LLVM-C.Peter Zotov9-385/+479
Also, rearrange the functions in a way that allows to quickly compare C headers and .mli/glue files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220842 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-28[OCaml] PR19859: Add functions to query and modify branches.Peter Zotov3-0/+140
Patch by Gabriel Radanne <drupyog@zoho.com>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220818 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-28[OCaml] PR19859: Add Llvm.{fcmp_predicate,float_of_const}.Peter Zotov3-0/+40
Patch by Gabriel Radanne <drupyog@zoho.com>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220815 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-28[OCaml] Enable -g for debug builds.Peter Zotov1-4/+3
We don't care about pre-3.12.1 anymore. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220767 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-28[OCaml] Fix whitespace.Peter Zotov13-65/+65
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220766 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-26[OCaml] Expose existing documentation in ocamldoc.Peter Zotov1-43/+43
Patch by Gabriel Radanne <drupyog@zoho.com>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220648 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-25[OCaml] Unbreak Llvm_executionengine.initialize_native_target.Peter Zotov1-14/+16
First, return true on success, as it is the OCaml convention. Second, also initialize the native assembly printer, which is, despite the name, required for MCJIT operation. Since this function did not initialize the assembly printer earlier and no function to initialize native assembly printer was available elsewhere, it is safe to break its interface: it means that it simply could not be used successfully before. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220620 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-25[OCaml] Expose Llvm_executionengine.ExecutionEngine.create_mcjit.Peter Zotov3-27/+103
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220619 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-23Add llvm-go tool.Peter Collingbourne1-41/+5
This tool lets us build LLVM components within the tree by setting up a $GOPATH that resembles a tree fetched in the normal way with "go get". It is intended that components such as the Go frontend will be built in-tree using this tool. Differential Revision: http://reviews.llvm.org/D5902 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220462 91177308-0d34-0410-b5e6-96231b3b80d8