Commit Graph

213 Commits

Author SHA1 Message Date
Michael Gottesman
abaa85d88d [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190477 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 01:38:12 +00:00
Michael Gottesman
73c382f7fd [python-bindings] Added support for iterating over a basic blocks instructions, getting their name/dumping them, f/b iteration.
Tests are included.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190475 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 01:17:38 +00:00
Michael Gottesman
e23fa984f5 [python-bindings] Added support for iterating over a function's basic blocks, dumping/getting names of those bb, f/w iteration.
Tests are included.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190473 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 01:01:40 +00:00
Michael Gottesman
7dfa4bc471 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190471 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 00:52:47 +00:00
Michael Gottesman
f532d44830 [python-bindings] Export OpCode from core.py.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190468 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 00:41:07 +00:00
Michael Gottesman
a1e366058b [python-bindings] Added test for reading a module from bitcode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190467 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 00:41:05 +00:00
Michael Gottesman
7400a858be [python-bindings] Fixed 3 test failures caused by typos.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190465 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 00:41:02 +00:00
Michael Gottesman
f495a26792 Fixed typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190459 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 00:27:23 +00:00
Michael Gottesman
37a8807323 [python-bindings] Added code for loading a module from bitcode, getset its datalayout, getset its target, dump it, print it to a file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190458 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 00:23:14 +00:00
Michael Gottesman
6a63cd1281 [python-bindings] Added bindings for LLVMContextRef and a test for creating a new context or getting the global context.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190457 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 00:23:10 +00:00
Michael Gottesman
8184ca673b [python-bindings] Implemented the PassRegistry class and the calls to initialize/shutdown llvm. Also included an initialize_llvm declaration.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190456 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 00:23:08 +00:00
Michael Gottesman
699f8c3524 [python-bindings] Removed unused import byref from llvm/disassembler.py.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190455 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-11 00:23:05 +00:00
Michael Gottesman
86942d20b9 [python-bindings] Changed test_memory_buffer_create_from_file to just use the generic provided test_file instead of a binary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190389 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10 06:58:00 +00:00
Michael Gottesman
653212fdd1 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190388 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10 06:57:57 +00:00
Bill Wendling
0c25b8f07e We're in 3.4 land now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181350 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-07 20:31:28 +00:00
Andrew Kaylor
d2755af8bd 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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180720 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-29 17:49:40 +00:00
Andrew Kaylor
2f5640d637 Fixing OCAML bindings for MCJIT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180232 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-25 00:03:58 +00:00
Gregory Szorc
fdddf77171 [python] Add markup option to disassembler
Patch contributed by Wladimir J. van der Laan <laanwj@gmail.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169102 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-01 21:57:30 +00:00
Anders Waldenborg
17cfe87c39 [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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168390 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-20 22:27:55 +00:00
Micah Villmow
28ce1cc183 Fix a build error for ocaml bindings that was introduced with the TargetData --> DataLayout changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166309 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-19 20:36:22 +00:00
Micah Villmow
e2c207db1d Fix the ocaml binding breakage from TargetData -> DataLayout changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165406 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-08 17:06:25 +00:00
Micah Villmow
791cfc211a Move TargetData to DataLayout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165403 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-08 16:39:34 +00:00
Nuno Lopes
4d00161e0a add support for ocaml 3.12
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163096 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-02 14:42:56 +00:00
Bill Wendling
df6c55155c Remove tabs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160482 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-19 00:23:13 +00:00
Anders Waldenborg
e3295cc5be [python] Add negative MemoryBuffer testcase
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153248 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-22 11:23:52 +00:00
Anders Waldenborg
a8d873e178 [python] Add some paths where to find test binary
Adds /usr/lib/debug early to list, as some systems (debian) have unstripped libs in there
Adds /lib/i386-linux-gnu for systems that does multiarch (debian)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153174 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-21 08:34:58 +00:00
Anders Waldenborg
3595954130 [python] Mark get_test_binary as not being a test
get_test_binary is a helper method, not a test, make sure nosetests
doesn't pick it up as a test.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153173 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-21 08:18:19 +00:00
Gregory Szorc
92a3e9d63a [llvm.py] Implement disassembler interface
It doesn't currently support the op info and symbol lookup callbacks,
but it is better than nothing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152527 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-11 02:32:56 +00:00
Gregory Szorc
309a2c4e3b Revert "[llvm.py] Implement interface to enhanced disassembler"
Chris Lattner says the edis interface is going away. It doesn't make
sense to land something that will go away in the near future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152508 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-10 21:44:03 +00:00
Gregory Szorc
0b3aae906f [llvm.py] Implement interface to enhanced disassembler
This requires a C++ change to EDDisassembler's ctor to function properly
(the llvm::InitializeAll* functions aren't being called currently and
there is no way to call them from Python).

Code is partially tested and works well enough for initial commit. There
are probably many small bugs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152506 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-10 21:05:05 +00:00
Gregory Szorc
d3ac784fbb [llvm.py] Make LLVMObject.__del__ work if called during __init__
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152505 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-10 21:01:14 +00:00
Gregory Szorc
b7487d4edc [llvm.py] Define enumerations from Core.h; add OpCode class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152483 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-10 05:50:56 +00:00
Gregory Szorc
61e22cd85c [llvm.py] Implement interface to object files
It is now possible to load object files and scan over sections, symbols,
and relocations! Includes test code with partial coverage.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152482 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-10 04:41:24 +00:00
Gregory Szorc
07c32218f4 [llvm.py] Make ObjectFile destructor work
Previous code had a double free in MemoryBuffer. The tests now pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152422 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-09 18:56:33 +00:00
Gregory Szorc
5ae04279e0 [llvm.py] Initial skeleton for Python LLVM bindings
This contains a semi-functional skeleton for the implementation of the
LLVM bindings for Python.

The API for the Object.h interface is roughly designed but not
implemented. MemoryBufferRef is implemented and actually appears to
work!

The ObjectFile unit test fails with a segmentation fault because the
LLVM library isn't being properly initialized. The build system doesn't
know about this code yet, so no alerts should fire.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152397 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-09 09:07:35 +00:00
Benjamin Kramer
efde86753d ocaml bindings: landing pad is now the last opcode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149997 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-07 18:58:19 +00:00
Jim Grosbach
c48d4dc8a9 Tidy up. s/Low Level Virtual Machine/LLVM/.
LLVM isn't an acronym anymore.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148985 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-25 22:00:23 +00:00
Bob Wilson
eaf0608891 Update OCaml bindings for the new half float type.
Patch by Jonathan Ragan-Kelley!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147314 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-28 18:51:08 +00:00
Dylan Noblesmith
9421406aad drop unneeded config.h includes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147197 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-22 23:04:07 +00:00
Daniel Dunbar
4ab406d7fc LLVMBuild: Remove trailing newline, which irked me.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146409 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-12 19:48:00 +00:00
Wojciech Matyjewicz
6f274a5e81 Minor fixes in Makefiles for the OCaml bindings:
1. Interface files (.mli) are installed before compiled interface
   files (.cmi) to preserve timestamp relation.
2. install-meta should use $(OcamlDir) instead of $(ObjDir).
3. Declared some targets as .PHONY.

Patch by Christophe Raffalli.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144183 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-09 12:00:39 +00:00
Daniel Dunbar
a3a2dfd4a2 build: Add initial cut at LLVMBuild.txt files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143634 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-03 18:53:17 +00:00
Torok Edwin
ff616cb440 OCaml bindings: add some missing functions and testcases.
The C bindings exposed some APIs that weren't covered by the OCaml bindings

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141997 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:38:33 +00:00
Torok Edwin
0be167bab2 OCaml bindings: fix attributes to use all 32 bits
OCaml's int is limited to 31 bits on 32-bit architectures, so use Int32
explicitly.
Also add an unpack_attr, and {function,param,instr}_attr functions to read
the attributes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141996 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:38:24 +00:00
Torok Edwin
8da43bf60e OCaml bindings: add icmp_predicate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141995 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:38:19 +00:00
Torok Edwin
2c4ae181c4 OCaml bindings: fix infinite recursion on string_of_lltype
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141994 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:38:14 +00:00
Torok Edwin
6b228e506f bindings: named struct support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141993 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:38:08 +00:00
Torok Edwin
4c4b71cec5 ocaml bindings: add findlib META support
This makes it easier to link against LLVM libs, especially if you are using
_oasis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141992 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:38:02 +00:00
Torok Edwin
3dd1674186 ocaml bindings: introduce classify_value
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141991 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:37:56 +00:00
Torok Edwin
6563c87996 ocaml bindings: add getopcode for constant and instruction, and int64_of_const.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141990 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:37:49 +00:00