1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00
Commit Graph

439 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
14d896c4af IR: Remove MDTupleTypedArrayWrapper::operator MDTuple*()
Remove `MDTupleTypedArrayWrapper::operator MDTuple*()`, since it causes
ambiguity (at least in some [1] compilers [2]) when using indexes to
`MDTupleTypedArrayWrapper::operator[](unsigned)` that are convertible to
(but not the same as) `unsigned`.

[1]: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/2308
[2]: http://lab.llvm.org:8011/builders/clang-cmake-mips/builds/4442

llvm-svn: 234326
2015-04-07 16:50:39 +00:00
Duncan P. N. Exon Smith
a2fe0f4138 bindings/go: Stop using DIDescriptor::is*() and auto-casting
Go bindings edition of r234255.

llvm-svn: 234262
2015-04-07 00:08:31 +00:00
Peter Collingbourne
4f5a1f3321 Go bindings: use MDNode::replaceAllUsesWith instead of MDTuple::replaceAllUsesWith.
Fixes llgo following Duncan's changes to debug info in r231082. llgo needs
to replace composite types, which are no longer represented using MDTuple.

llvm-svn: 231416
2015-03-05 22:55:38 +00:00
Juergen Ributzka
83001503ac Restore LLVMLinkModules C API until it is properly deprecated.
Add the enum "LLVMLinkerMode" back for backwards-compatibility and add the
linker mode parameter back to the "LLVMLinkModules" function. The paramter is
ignored and has no effect.

Patch provided by: Filip Pizlo
Reviewed by: Rafael and Sean

llvm-svn: 230988
2015-03-02 18:59:38 +00:00
Andrew Wilkins
cbb87b12f3 bindings/go: expose DIBuilder::createReplaceableCompositeType
Summary:
We extend the DIBuilder type, adding a method for creating
replaceable composite types. This is necessary for creating
debug info describing self-referential types.

Reviewers: pcc

Reviewed By: pcc

Subscribers: axw, llvm-commits

Differential Revision: http://reviews.llvm.org/D7851

llvm-svn: 230951
2015-03-02 12:27:04 +00:00
Chandler Carruth
18e8c62883 [PM] Remove the old 'PassManager.h' header file at the top level of
LLVM's include tree and the use of using declarations to hide the
'legacy' namespace for the old pass manager.

This undoes the primary modules-hostile change I made to keep
out-of-tree targets building. I sent an email inquiring about whether
this would be reasonable to do at this phase and people seemed fine with
it, so making it a reality. This should allow us to start bootstrapping
with modules to a certain extent along with making it easier to mix and
match headers in general.

The updates to any code for users of LLVM are very mechanical. Switch
from including "llvm/PassManager.h" to "llvm/IR/LegacyPassManager.h".
Qualify the types which now produce compile errors with "legacy::". The
most common ones are "PassManager", "PassManagerBase", and
"FunctionPassManager".

llvm-svn: 229094
2015-02-13 10:01:29 +00:00
Chandler Carruth
a89d62b417 Re-sort the #include lines in bindings and examples which I managed to
miss previously.

llvm-svn: 229089
2015-02-13 09:14:30 +00:00
Peter Zotov
33491f3d18 [OCaml] Add Llvm.build_empty_phi.
llvm-svn: 228395
2015-02-06 13:42:03 +00:00
Alexey Samsonov
f9eb672e1c SpecialCaseList: Add support for parsing multiple input files.
Summary:
This change allows users to create SpecialCaseList objects from
multiple local files. This is needed to implement a proper support
for -fsanitize-blacklist flag (allow users to specify multiple blacklists,
in addition to default blacklist, see PR22431).

DFSan can also benefit from this change, as DFSan instrumentation pass now
accepts ABI-lists both from -fsanitize-blacklist= and -mllvm -dfsan-abilist flags.

Go bindings are fixed accordingly.

Test Plan: regression test suite

Reviewers: pcc

Subscribers: llvm-commits, axw, kcc

Differential Revision: http://reviews.llvm.org/D7367

llvm-svn: 228155
2015-02-04 17:39:48 +00:00
Duncan P. N. Exon Smith
1368f89f93 IR: Return unique_ptr from MDNode::getTemporary()
Change `MDTuple::getTemporary()` and `MDLocation::getTemporary()` to
return (effectively) `std::unique_ptr<T, MDNode::deleteTemporary>`, and
clean up call sites.  (For now, `DIBuilder` call sites just call
`release()` immediately.)

There's an accompanying change in each of clang and polly to use the new
API.

llvm-svn: 226504
2015-01-19 21:30:18 +00:00
Duncan P. N. Exon Smith
0341a8121b IR: Remove MDNodeFwdDecl
Remove `MDNodeFwdDecl` (as promised in r226481).  Aside from API
changes, there's no real functionality change here.
`MDNode::getTemporary()` now forwards to `MDTuple::getTemporary()`,
which returns a tuple with `isTemporary()` equal to true.

The main point is that we can now add temporaries of other `MDNode`
subclasses, needed for PR22235 (I introduced `MDNodeFwdDecl` in the
first place because I didn't recognize this need, and thought they were
only needed to handle forward references).

A few things left out of (or highlighted by) this commit:

  - I've had to remove the (few) uses of `std::unique_ptr<>` to deal
    with temporaries, since the destructor is no longer public.
    `getTemporary()` should probably return the equivalent of
    `std::unique_ptr<T, MDNode::deleteTemporary>`.
  - `MDLocation::getTemporary()` doesn't exist yet (worse, it actually
    does exist, but does the wrong thing: `MDNode::getTemporary()` is
    inherited and returns an `MDTuple`).
  - `MDNode` now only has one subclass, `UniquableMDNode`, and the
    distinction between them is actually somewhat confusing.

I'll fix those up next.

llvm-svn: 226501
2015-01-19 20:36:39 +00:00
Peter Zotov
b21759952e [OCaml] Allow out-of-tree builds of LLVM bindings.
In order to use this feature, configure LLVM as usual,
but then build and install it as:

   make all install SYSTEM_LLVM_CONFIG=llvm-config

where llvm-config is the llvm-config binary installed on your
system (possibly llvm-config-VERSION on e.g. Debian).

llvm-svn: 225787
2015-01-13 12:17:56 +00:00
Peter Zotov
807dc63755 [OCaml] Use $CAMLORIGIN, an rpath-$ORIGIN-like mechanism in OCaml.
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.

llvm-svn: 225778
2015-01-13 09:47:59 +00:00
Peter Zotov
f7e64121ed [OCaml] [cmake] Use LLVM_LIBRARY_DIR instead of LLVM_LIBRARY_OUTPUT_INTDIR.
The latter variable is internal.

Original patch by Ramkumar Ramachandra <artagnon@gmail.com>

llvm-svn: 224977
2014-12-30 03:24:07 +00:00
Peter Zotov
52abf62de2 [OCaml] Expose Llvm_executionengine.get_{global_value,function}_address.
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.

llvm-svn: 224801
2014-12-24 01:52:51 +00:00
Rafael Espindola
e3ea3709d0 Finish removing DestroySource.
Fixes pr21901.

llvm-svn: 224782
2014-12-23 19:16:45 +00:00
Peter Zotov
41942af9a1 [OCaml] PR22014: OCaml bindings didn't link to libLLVM-*.so with -Wl,--as-needed
Patch by Evangelos Foutras <evangelos@foutrelis.com>.

llvm-svn: 224766
2014-12-23 13:09:59 +00:00
Peter Collingbourne
429456643c Go bindings: introduce Value.ConstantAsMetadata.
llvm-svn: 224179
2014-12-13 02:25:57 +00:00
Peter Collingbourne
bcdc22d6ac Go bindings: introduce llvm.TemporaryMDNode.
llvm-svn: 224178
2014-12-13 02:25:54 +00:00
Peter Collingbourne
35ba0efe81 Go bindings: introduce Metadata.ReplaceAllUsesWith.
llvm-svn: 224177
2014-12-13 02:25:51 +00:00
Peter Collingbourne
1b01b3d54e Go bindings: expose the Metadata type.
Also modifies SetCurrentDebugLocation to take individual arguments rather
than an MDNode.

llvm-svn: 224176
2014-12-13 02:25:49 +00:00
Peter Collingbourne
d742e77547 Go bindings: remove contextless metadata bindings.
llvm-svn: 224175
2014-12-13 02:25:45 +00:00
Duncan P. N. Exon Smith
3d57886267 IR: Split Metadata from Value
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.)

llvm-svn: 223802
2014-12-09 18:38:53 +00:00
Eric Christopher
ba5c88412a Add bindings for the rest of the MCJIT options that we previously
had support for. We're still missing a binding for an MCJIT
memory manager.

llvm-svn: 223153
2014-12-02 21:09:01 +00:00
Peter Zotov
a5a15255cc [OCaml] Add Llvm.mdnull.
Patch by Gideon Smeding <gideon.smeding@3ds.com>.

llvm-svn: 223129
2014-12-02 17:35:26 +00:00
Peter Zotov
a7ec66eea2 [OCaml] Move Llvm.clone_module to its own Llvm_transform_utils module.
This way most code won't link this (substantially large) library,
if compiled statically with LLVM.

llvm-svn: 223072
2014-12-01 19:50:39 +00:00
Peter Zotov
a05f11b29b [OCaml] [cmake] Add CMake buildsystem for OCaml.
Closes PR15325.

llvm-svn: 223071
2014-12-01 19:50:23 +00:00
Eric Christopher
ed0a2aa2b2 Reformat with gofmt.
llvm-svn: 222806
2014-11-26 02:57:33 +00:00
Eric Christopher
da77ae7155 Make SetMCJITOptimizationLevel more of a method and pass options
as a reference. Move closer to the type.

llvm-svn: 222805
2014-11-26 02:54:24 +00:00
Eric Christopher
9c25973a19 Make sure that the go bindings call LLVMInitializeMCJITCompilerOptions
so that they initialize the code generation model to the correct
(non-zero) default model.

llvm-svn: 222804
2014-11-26 02:27:46 +00:00
Peter Collingbourne
d28ac9a35d Go bindings: add DIBuilder.InsertValueAtEnd
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

llvm-svn: 222790
2014-11-25 21:05:04 +00:00
Peter Collingbourne
a8e90e764e Expose LLVM version string via macro in llvm-config.h, and modify Go bindings
to make use of it.

llvm-svn: 222307
2014-11-19 03:34:17 +00:00
Peter Zotov
9d80aec36c [OCaml] Fix mismatched CAMLparam/CAMLreturn.
Also, revert r221142--it was an incorrect fix to this bug
which fixed tests by accident.

llvm-svn: 221149
2014-11-03 11:47:14 +00:00
Peter Zotov
260d1b1b77 [OCaml] Add -g on DEBUG_SYMBOLS=1, not ENABLE_OPTIMIZED.
Thanks echristo for pointing this out.

llvm-svn: 221145
2014-11-03 10:06:19 +00:00
Peter Zotov
7c29a0fdaf [OCaml] Don't use deprecated non-caml_namespaced functions.
llvm-svn: 221143
2014-11-03 09:51:47 +00:00
Peter Zotov
bbaea64b40 [OCaml] Initialize local roots prior to raising.
On 4.02, the OCaml unwinder otherwise gets confused and segfaults.

llvm-svn: 221142
2014-11-03 09:51:44 +00:00
Peter Zotov
772c8edf96 [OCaml] Core package should depend on LLVMTransformUtils for LLVMCloneModule.
llvm-svn: 221141
2014-11-03 09:51:41 +00:00
Peter Zotov
b4e4fed74d [OCaml] Fix ocamlc -custom builds when configured as --enable-shared.
llvm-svn: 221140
2014-11-03 09:51:37 +00:00
Peter Zotov
3c929e8a6a [OCaml] Avoid embedding absolute paths into executables.
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.

llvm-svn: 221139
2014-11-03 09:51:34 +00:00
Peter Zotov
ee1171d3fa [OCaml] Don't build stub libraries twice.
The default Makefile.rules BUILD_ARCHIVE machinery was
unintentionally enabled.

llvm-svn: 221138
2014-11-03 09:51:28 +00:00
Peter Zotov
3ab83ce133 [OCaml] META: remove exists_if(toplevel).
ocamlfind ignores the predicates in this case, making the package
unavailable for batch compilation as well.

llvm-svn: 221136
2014-11-03 09:50:02 +00:00
Peter Zotov
3d9a356a60 [OCaml] ExecutionEngine package should not depend on interpreter.
Interpreter support was removed in r220957.

llvm-svn: 221135
2014-11-03 09:49:42 +00:00
Peter Zotov
c92484316f [OCaml] Ensure consistent naming.
Specifically:
  * Directories match module names.
  * Test names match module names.
  * The language is called "OCaml", not "Ocaml".

llvm-svn: 220958
2014-10-31 09:19:03 +00:00
Peter Zotov
5dda7d9855 [OCaml] Rework Llvm_executionengine using ctypes.
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.

llvm-svn: 220957
2014-10-31 09:05:36 +00:00
Peter Zotov
6107c0888e [OCaml] Expose LLVMCloneModule.
llvm-svn: 220903
2014-10-30 08:30:12 +00:00
Peter Zotov
63938c8558 [OCaml] Expose LLVM{Get,Set}DLLStorageClass.
llvm-svn: 220902
2014-10-30 08:30:08 +00:00
Peter Zotov
c22ad454f5 [OCaml] [autoconf] Migrate to ocamlfind.
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.

llvm-svn: 220899
2014-10-30 08:29:45 +00:00
Peter Zotov
c758afd8d3 [OCaml] De-duplicate llvm_raise and llvm_string_of_message.
llvm-svn: 220898
2014-10-30 08:29:29 +00:00
Peter Zotov
baffd2af6d [OCaml] Expose Llvm.parse_command_line_options.
llvm-svn: 220847
2014-10-29 08:16:18 +00:00
Peter Zotov
f1fa95c061 [OCaml] Expose Llvm_target.TargetMachine.add_analysis_passes.
llvm-svn: 220846
2014-10-29 08:16:14 +00:00
Peter Zotov
7624f67acb [OCaml] If compiled without --enable-shared, hide packages from toplevel.
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.

llvm-svn: 220845
2014-10-29 08:16:06 +00:00
Peter Zotov
abfbb4539f [OCaml] Expose Llvm_bitwriter.write_bitcode_to_memory_buffer.
llvm-svn: 220844
2014-10-29 08:16:01 +00:00
Peter Zotov
92738ae9a2 [OCaml] Drop support for 3.12.1 and earlier.
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.

llvm-svn: 220843
2014-10-29 08:15:54 +00:00
Peter Zotov
f7af23baaa [OCaml] Synchronize transformations with LLVM-C.
Also, rearrange the functions in a way that allows to quickly
compare C headers and .mli/glue files.

llvm-svn: 220842
2014-10-29 08:15:21 +00:00
Peter Zotov
3a56d6667a [OCaml] PR19859: Add functions to query and modify branches.
Patch by Gabriel Radanne <drupyog@zoho.com>.

llvm-svn: 220818
2014-10-28 19:47:02 +00:00
Peter Zotov
927677ad96 [OCaml] PR19859: Add Llvm.{fcmp_predicate,float_of_const}.
Patch by Gabriel Radanne <drupyog@zoho.com>.

llvm-svn: 220815
2014-10-28 19:46:48 +00:00
Peter Zotov
da5425e252 [OCaml] Enable -g for debug builds.
We don't care about pre-3.12.1 anymore.

llvm-svn: 220767
2014-10-28 06:15:41 +00:00
Peter Zotov
41625b6878 [OCaml] Fix whitespace.
llvm-svn: 220766
2014-10-28 06:15:18 +00:00
Peter Zotov
7de838bfe6 [OCaml] Expose existing documentation in ocamldoc.
Patch by Gabriel Radanne <drupyog@zoho.com>.

llvm-svn: 220648
2014-10-26 20:45:22 +00:00
Peter Zotov
a9b429237d [OCaml] Unbreak Llvm_executionengine.initialize_native_target.
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.

llvm-svn: 220620
2014-10-25 18:50:02 +00:00
Peter Zotov
4e58408520 [OCaml] Expose Llvm_executionengine.ExecutionEngine.create_mcjit.
llvm-svn: 220619
2014-10-25 18:49:56 +00:00
Peter Collingbourne
65b92cb354 Add llvm-go tool.
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

llvm-svn: 220462
2014-10-23 02:33:23 +00:00
Peter Collingbourne
995034d1b1 Go: add binding for LLVMSetUnnamedAddr.
llvm-svn: 220416
2014-10-22 20:20:27 +00:00
Peter Zotov
f8c5e569b2 [OCaml] Fix a typo in documentation.
llvm-svn: 220377
2014-10-22 10:24:05 +00:00
Peter Collingbourne
eb8bba56de Fix bashism in build.sh.
llvm-svn: 220027
2014-10-17 02:20:40 +00:00
Peter Zotov
c5418e39bd [OCaml] Add Llvm.instr_clone.
llvm-svn: 220008
2014-10-17 01:02:40 +00:00
Peter Collingbourne
22590da2c9 Initial version of Go bindings.
This code is based on the existing LLVM Go bindings project hosted at:
https://github.com/go-llvm/llvm

Note that all contributors to the gollvm project have agreed to relicense
their changes under the LLVM license and submit them to the LLVM project.

Differential Revision: http://reviews.llvm.org/D5684

llvm-svn: 219976
2014-10-16 22:48:02 +00:00
Eric Christopher
2f6f860aaa Reinstate "Nuke the old JIT."
Approved by Jim Grosbach, Lang Hames, Rafael Espindola.

This reinstates commits r215111, 215115, 215116, 215117, 215136.

llvm-svn: 216982
2014-09-02 22:28:02 +00:00
Peter Zotov
637a91873c [OCaml] Expose Llvm.get_operand_use.
Patch by Gabriel Radanne <drupyog@zoho.com>

llvm-svn: 215420
2014-08-12 02:55:45 +00:00
Eric Christopher
378bc328f0 Temporarily Revert "Nuke the old JIT." as it's not quite ready to
be deleted. This will be reapplied as soon as possible and before
the 3.6 branch date at any rate.

Approved by Jim Grosbach, Lang Hames, Rafael Espindola.

This reverts commits r215111, 215115, 215116, 215117, 215136.

llvm-svn: 215154
2014-08-07 22:02:54 +00:00
Rafael Espindola
3b51160f99 Fix the ocaml bindings.
llvm-svn: 215117
2014-08-07 14:48:13 +00:00
Peter Zotov
4fc6b74b35 [OCaml] Add Llvm.{string_of_const,const_element}.
llvm-svn: 214677
2014-08-03 23:54:22 +00:00
Peter Zotov
f79b84b24e [OCaml] Don't truncate constants over 32 bits in Llvm.const_int.
llvm-svn: 213655
2014-07-22 13:55:20 +00:00
Gerolf Hoflehner
5fa7774dfd MergedLoadStoreMotion pass
Merges equivalent loads on both sides of a hammock/diamond
and hoists into into the header.
Merges equivalent stores on both sides of a hammock/diamond
and sinks it to the footer.
Can enable if conversion and tolerate better load misses
and store operand latencies.

llvm-svn: 213396
2014-07-18 19:13:09 +00:00
Peter Zotov
171cddf9b3 [OCaml] Documentation improvements.
Patch by Julien Sagot

llvm-svn: 212230
2014-07-02 22:17:20 +00:00
Peter Zotov
f99a42bc31 [OCaml] Documentation improvements.
llvm-svn: 212048
2014-06-30 16:53:53 +00:00
Peter Zotov
5c56850c1f [OCaml] Unbreak Llvm_target.TargetMachine.set_verbose_asm
Patch by Jacques-Pascal Deplaix

llvm-svn: 210480
2014-06-09 17:34:34 +00:00
Peter Zotov
06677a2162 [OCaml] Commit missing parts of r210395
llvm-svn: 210396
2014-06-07 15:53:28 +00:00
Peter Zotov
ec3618d58d [OCaml] Introduce an llmdkind abstract type.
Patch by Gabriel Radanne.

While this commit technically breaks API, no code should have supplied
the integer IDs directly, and thus no code should break.

llvm-svn: 210395
2014-06-07 15:15:10 +00:00
Peter Zotov
a7bda7bc0b [OCaml] Add an ocamlfind package llvm.all_backends.
This package is useful for architecture-independent tools like llc.

Patch by Jacques-Pascal Deplaix.

llvm-svn: 207793
2014-05-01 21:00:52 +00:00
Anders Waldenborg
f342831239 [python] Fix getting section contents.
The returnvalue was handled as c_char_p which ment that ctypes
handled it as a NUL-terminated string making it cut the contents
at first NUL (or even worse - overrunning the buffer if it doesn't
contain a NUL).

Differential Revision: http://reviews.llvm.org/D3474

llvm-svn: 207199
2014-04-25 06:25:15 +00:00
Anders Waldenborg
0a7dc3330f [python] Fix python bindings tests
Broke after the changes related to the LLVMGetSymbolFileOffset
removal in r206750

llvm-svn: 207018
2014-04-23 20:32:03 +00:00
Rafael Espindola
56c64fd6fd Convert getFileOffset to getOffset and move it to its only user.
We normally don't drop functions from the C API's, but in this case I think we
can:

* The old implementation of getFileOffset was fairly broken
* The introduction of LLVMGetSymbolFileOffset was itself a C api breaking
  change as it removed LLVMGetSymbolOffset.
* It is an incredibly specialized use case. The only reason MCJIT needs it is
  because of its odd position of being a dynamic linker of .o files.

llvm-svn: 206750
2014-04-21 13:45:32 +00:00
Michael Gottesman
eec992195b [python-bindings] Remove some cruft that snuck in.
llvm-svn: 201966
2014-02-23 04:43:26 +00:00
Michael Gottesman
436376bfbc [python-bindings] Added OpCode like support for all enumerations with unittests.
Also fixed some trailing whitespace issues.

llvm-svn: 201929
2014-02-22 05:39:35 +00:00
NAKAMURA Takumi
0c7582f249 Makefile.ocaml: Tweak to use --system-libs.
llvm-svn: 197758
2013-12-20 00:36:59 +00:00
Alp Toker
20f2bae8eb Fix documentation typos
llvm-svn: 197757
2013-12-20 00:33:39 +00:00
Peter Zotov
f783e4243e [OCaml] Add a slash accidentally omitted from Makefile
llvm-svn: 195912
2013-11-28 09:03:28 +00:00
Peter Zotov
4ae3b7518c [OCaml] Embed rpath into stub libraries and native executables
This commit embeds a set of linker flags with hardcoded paths to
the LLVM shared library on --enable-shared builds into .cmxa files
and stub dynamic libraries. This solution closely follows existing
rules for rpath in the LLVM tools, which had to be modified because
of differences in toolchain.

Without this patch, OCaml tests as well as opam bindings broke,
as neither of those updates LD_LIBRARY_PATH to include
the $prefix/lib directory.

llvm-svn: 195834
2013-11-27 11:03:18 +00:00
Peter Zotov
e3fdb03df7 [OCaml] Embed the flags necessary for linking with libLLVM.so into .cmxa files
llvm-svn: 195782
2013-11-26 20:40:34 +00:00
Peter Zotov
770a3bbabb [OCaml] Unbreak make install by providing ocamldoc target
llvm-svn: 195336
2013-11-21 10:10:16 +00:00
Anders Waldenborg
5adf625df0 python: Fix check for disasm creation failure
Check should be for pointer being NULL, not what it points to.

Also adds a test for this case.

Reviewed By: indygreg

Differential Revision: http://llvm-reviews.chandlerc.com/D1878

llvm-svn: 194965
2013-11-17 15:40:57 +00:00
Anders Waldenborg
9ee62020d6 python: Properly initialize before trying to create disasm
As the "LLVMInitializeAll*" functions are not available as symbols in
the shared library they can't be used, and as a workaround a list of
the targets is kept and the individual symbols tried. As soon as the
"All"-functions are changed to proper symbols (as opposed to static
inlines in the headers) this hack will be replace with simple calls
to the corresponding "LLVMInitializeAll*" functions.

Reviewed By: indygreg

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1879

llvm-svn: 194964
2013-11-17 15:17:08 +00:00
Peter Zotov
ec8c29b1d7 [OCaml] Add Target and TargetMachine bindings to Llvm_target
llvm-svn: 194774
2013-11-15 02:51:57 +00:00
Peter Zotov
5d089306c3 [OCaml] Refactor Llvm_target interface
This commit brings the module structure, argument order and
primitive names in Llvm_target in order with the rest of the bindings,
in preparation for adding TargetMachine API.

llvm-svn: 194773
2013-11-15 02:51:44 +00:00
Peter Zotov
e66ae0045d [OCaml] Fix building of stub libraries
llvm-svn: 194772
2013-11-15 02:51:27 +00:00
Peter Zotov
e0c727aff0 [OCaml] Build stub OCaml libraries for all configured targets
This allows to only link in the needed targets, reducing binary
size and more importantly link time.

Note that this is an incomplete implementation: currently,
LLVM does not have the plumbing which would allow to conditionally
link in AsmPrinter, AsmParser and Disassembler for the targets
which support them. This should be improved in the future.

llvm-svn: 194670
2013-11-14 06:34:21 +00:00
Peter Zotov
b192fa5024 [OCaml] Expose LLVM's fatal error and stacktrace APIs
llvm-svn: 194669
2013-11-14 06:34:13 +00:00
Peter Zotov
b163e08a96 [OCaml] Dynamically link LLVM on --enable-shared builds
This commit significantly speeds up both bytecode and native
builds of LLVM clients (from ~20 second to sub-second link time),
and allows to invoke LLVM functions from OCaml toplevel.

The behavior for --disable-shared builds is unchanged.

llvm-svn: 194509
2013-11-12 20:55:49 +00:00
Peter Zotov
215b4eb081 [OCaml] Fix a typo
llvm-svn: 194508
2013-11-12 20:55:42 +00:00
Peter Zotov
83f140c801 [OCaml] Add missing Llvm_target functions
llvm-svn: 194382
2013-11-11 14:47:28 +00:00
Peter Zotov
7456a45c87 [OCaml] Accept context explicitly in Llvm_target functions
Llvm_target.intptr_type used to implicitly use global context. As
none of other functions in OCaml bindings do, it is changed to
accept context explicitly.

llvm-svn: 194381
2013-11-11 14:47:20 +00:00
Peter Zotov
4625440ac9 [OCaml] Make Llvm_target.DataLayout.t automatically managed
This breaks the API by removing Llvm_target.DataLayout.dispose.

llvm-svn: 194380
2013-11-11 14:47:11 +00:00
Peter Zotov
fe15a570ea [OCaml] Impement Llvm_irreader, bindings to LLVM assembly parser
llvm-svn: 194138
2013-11-06 09:21:25 +00:00
Peter Zotov
7e2a601991 [OCaml] Implement Llvm.string_of_llvalue
llvm-svn: 194136
2013-11-06 09:21:08 +00:00
Peter Zotov
012a4ffd60 [OCaml] (PR16190) Add ValueKinds for ConstantDataSequential and subclasses
Original patch by David Monniaux

llvm-svn: 194075
2013-11-05 12:55:43 +00:00
Peter Zotov
09f34ca4b9 [OCaml] (PR16318) Add missing argument to Llvm.const_intcast
llvm-svn: 194065
2013-11-05 11:56:20 +00:00
Peter Zotov
118bf8ac38 [OCaml] (PR11717) Make declare_qualified_global respect address argument
Original patch by Jonathan Ragan-Kelley

llvm-svn: 194064
2013-11-05 11:56:13 +00:00
Peter Zotov
7bb25c41d3 [OCaml] Properly tag the custom operations of Llvm.llbuilder
All other custom operations tags have LLVM prefix.

llvm-svn: 194058
2013-11-05 09:13:46 +00:00
Peter Zotov
615991b419 [OCaml] Llvm_linker: do not use external in module interface
Workaround for an OCaml bug:
http://caml.inria.fr/mantis/view.php?id=4166

llvm-svn: 194057
2013-11-05 09:13:39 +00:00
Peter Zotov
4b13ee5f62 [OCaml] implement Llvm_passmgr_builder, bindings for PassManagerBuilder
llvm-svn: 193968
2013-11-04 01:39:42 +00:00
Peter Zotov
23e94a56d9 [OCaml] Documentation
llvm-svn: 193967
2013-11-04 01:39:31 +00:00
Peter Zotov
22f34b9373 [OCaml] Implement missing LLVMCore APIs
llvm-svn: 193966
2013-11-04 01:39:26 +00:00
Peter Zotov
d01f123fa7 [OCaml] Formatting
llvm-svn: 193965
2013-11-04 01:39:18 +00:00
Peter Zotov
47beae7a65 [OCaml] Implement Llvm.MemoryBuffer.{of_string,as_string}
llvm-svn: 193953
2013-11-03 08:27:45 +00:00
Peter Zotov
57d8f2c2e9 [OCaml] Fix ABI incompatibility
OCaml's type unit is not compatible with C's type void.

llvm-svn: 193952
2013-11-03 08:27:37 +00:00
Peter Zotov
aa2a604cf0 [OCaml] Implement Llvm_linker, bindings for the IR linker
llvm-svn: 193951
2013-11-03 08:27:32 +00:00
Peter Zotov
2aba543196 [OCaml] Implement Llvm_vectorize bindings
llvm-svn: 193950
2013-11-03 08:27:22 +00:00
Peter Zotov
500cb8d4ee [OCaml] Llvm_target: fix typo (Int_val instead of Int64_val)
llvm-svn: 193948
2013-11-03 08:27:08 +00:00
Peter Zotov
9e58e5ad83 [OCaml] Llvm_scalar_opts: add missing transforms
llvm-svn: 193946
2013-11-03 07:54:17 +00:00
Peter Zotov
d9e82e73c8 [OCaml] Llvm_ipo: add missing transforms
llvm-svn: 193945
2013-11-03 07:54:08 +00:00
Sylvestre Ledru
08e83c3930 OCaml bindings: fix typo
Patch by Peter Zotov

llvm-svn: 193851
2013-11-01 02:29:13 +00:00
Sylvestre Ledru
9f107a3782 OCaml bindings: remove unused DONT_BUILD_RELINKED from Makefiles
Patch by Peter Zotov

llvm-svn: 193847
2013-11-01 01:14:24 +00:00
Sylvestre Ledru
3cdf499ddf OCaml bindings: fix typo
Patch by Peter Zotov

llvm-svn: 193845
2013-11-01 01:10:58 +00:00
Sylvestre Ledru
8dbae1013d OCaml bindings: fix typo in documentation
Patch by Peter Zotov

llvm-svn: 193838
2013-11-01 00:30:02 +00:00
Sylvestre Ledru
f2e94c88f0 OCaml bindings: formatting
This commit only changes comments and documentation in OCaml bindings. The official name of the language is OCaml, and the usage is now consistent.

Patch by Peter Zotov

llvm-svn: 193836
2013-11-01 00:26:01 +00:00
Michael Gottesman
16531da862 [python-bindings] Added support for getting/setting operands of values and getting the number of operands of a value.
Also in the process did some cleanups for BasicBlock.

llvm-svn: 190477
2013-09-11 01:38:12 +00:00
Michael Gottesman
7e163e45bf [python-bindings] Added support for iterating over a basic blocks instructions, getting their name/dumping them, f/b iteration.
Tests are included.

llvm-svn: 190475
2013-09-11 01:17:38 +00:00
Michael Gottesman
ae12b893bc [python-bindings] Added support for iterating over a function's basic blocks, dumping/getting names of those bb, f/w iteration.
Tests are included.

llvm-svn: 190473
2013-09-11 01:01:40 +00:00
Michael Gottesman
b956e822b0 [python-bindings] Added support for getting a module's functions, iterating f/b over said functions, dumping/print name of functions.
Tests are included as well.

llvm-svn: 190471
2013-09-11 00:52:47 +00:00
Michael Gottesman
e9968bba4f [python-bindings] Export OpCode from core.py.
llvm-svn: 190468
2013-09-11 00:41:07 +00:00
Michael Gottesman
2df6576b7f [python-bindings] Added test for reading a module from bitcode.
llvm-svn: 190467
2013-09-11 00:41:05 +00:00
Michael Gottesman
e3e842d196 [python-bindings] Fixed 3 test failures caused by typos.
llvm-svn: 190465
2013-09-11 00:41:02 +00:00
Michael Gottesman
0c33b9c4e7 Fixed typo.
llvm-svn: 190459
2013-09-11 00:27:23 +00:00
Michael Gottesman
fafe55f90e [python-bindings] Added code for loading a module from bitcode, getset its datalayout, getset its target, dump it, print it to a file.
llvm-svn: 190458
2013-09-11 00:23:14 +00:00
Michael Gottesman
2e080516e5 [python-bindings] Added bindings for LLVMContextRef and a test for creating a new context or getting the global context.
llvm-svn: 190457
2013-09-11 00:23:10 +00:00
Michael Gottesman
81cbb207c8 [python-bindings] Implemented the PassRegistry class and the calls to initialize/shutdown llvm. Also included an initialize_llvm declaration.
llvm-svn: 190456
2013-09-11 00:23:08 +00:00
Michael Gottesman
27027c011f [python-bindings] Removed unused import byref from llvm/disassembler.py.
llvm-svn: 190455
2013-09-11 00:23:05 +00:00
Michael Gottesman
43af76e63d [python-bindings] Changed test_memory_buffer_create_from_file to just use the generic provided test_file instead of a binary.
llvm-svn: 190389
2013-09-10 06:58:00 +00:00
Michael Gottesman
c0820b7131 [python bindings] Added code to get the length of a memory buffer. Tests are included.
This is a part of a series of patches that have been sitting fallow on a
personal branch that I have been messing with for a bit.

The patches start to flesh out the python llvm-c wrapper to the point where you can:

1. Load Modules from Bitcode/Dump/Print them.
2. Iterate over Functions from those modules/get their names/dump them.
3. Iterate over the BasicBlocks from said function/get the BB's name/dump it.
4. Iterate over the Instructions in said BasicBlocks/get the instructions
   name/dump the instruction.

My main interest in developing this was to be able to gather statistics about
LLVM IR using python scripts to speed up statistical profiling of different IR
level transformations (hence the focus on printing/dumping/getting names).

This is a gift from me to the LLVM community = ).

I am going to be committing the patches slowly over the next bit as I have time
to prepare the patches.

The overall organization follows the c-api like the bindings that are already
implemented.

llvm-svn: 190388
2013-09-10 06:57:57 +00:00
Bill Wendling
f6be87cbaa We're in 3.4 land now.
llvm-svn: 181350
2013-05-07 20:31:28 +00:00
Andrew Kaylor
36788b2f65 Exposing MCJIT through C API
Re-submitting with fix for OCaml dependency problems (removing dependency on SectionMemoryManager when it isn't used).

Patch by Fili Pizlo

llvm-svn: 180720
2013-04-29 17:49:40 +00:00
Andrew Kaylor
be18a2273e Fixing OCAML bindings for MCJIT
llvm-svn: 180232
2013-04-25 00:03:58 +00:00
Gregory Szorc
dbb4e4372b [python] Add markup option to disassembler
Patch contributed by Wladimir J. van der Laan <laanwj@gmail.com>

llvm-svn: 169102
2012-12-01 21:57:30 +00:00
Anders Waldenborg
c07fe5ea4d [python] fix get_library()
Before this fix, the LLVM Python bindings on SVN trunk always fail with:
	Exception: LLVM shared library not found!
since it's still looking for a library named "LLVM-3.1svn".

Besides updating the LLVM version in the library name,
this patch also changes llvm.get_library() to make it possible to run
the unit tests without installing the LLVM shared library into a
default linker search path.

e.g. after this patch, running the llvm/python unit tests with:
LD_LIBRARY_PATH=../build/Debug+Asserts/lib nosetests -v bindings/python/llvm/tests/
would work on Linux.

Patch from Scott Tsai (with some minor modifications)

Patch also acked by Gregory Szorc

llvm-svn: 168390
2012-11-20 22:27:55 +00:00
Micah Villmow
4dcbb3e605 Fix a build error for ocaml bindings that was introduced with the TargetData --> DataLayout changes.
llvm-svn: 166309
2012-10-19 20:36:22 +00:00
Micah Villmow
c349103c68 Fix the ocaml binding breakage from TargetData -> DataLayout changes.
llvm-svn: 165406
2012-10-08 17:06:25 +00:00
Micah Villmow
fe3338a7eb Move TargetData to DataLayout.
llvm-svn: 165403
2012-10-08 16:39:34 +00:00
Nuno Lopes
9b3fce6457 add support for ocaml 3.12
llvm-svn: 163096
2012-09-02 14:42:56 +00:00
Bill Wendling
a3152cce75 Remove tabs.
llvm-svn: 160482
2012-07-19 00:23:13 +00:00