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

364 Commits

Author SHA1 Message Date
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