Added test/example for passes. Updated documentation.

git-svn-id: http://llvm-py.googlecode.com/svn/trunk@36 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
mdevan.foobar 2008-09-08 15:35:22 +00:00
commit 8eb5532b3a
13 changed files with 335 additions and 175 deletions

View file

@ -1,23 +1,27 @@
Contribute
==========
llvm-py is just hatching. It needs your patches and suggestions to
grow up. Please contribute! All patches are welcome. Here are some links
to start hacking away:
You can make a difference, just by:
`25`75~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Google code hosting, http://code.google.com/p/llvm-py/[http://code.google.com/p/llvm-py/]
Browse SVN, http://code.google.com/p/llvm-py/source/browse/[http://code.google.com/p/llvm-py/source/browse]
Issues tracker, http://code.google.com/p/llvm-py/issues/list[http://code.google.com/p/llvm-py/issues/list]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- getting llvm-py to work on an as-yet-untested platform
- adding support for more LLVM features into llvm-py
- sending in patches for bugs you come across
- improving the test scripts and documentation
- spreading the word
Useful links:
- Google code hosting: http://code.google.com/p/llvm-py/[http://code.google.com/p/llvm-py/]
- Browse SVN: http://code.google.com/p/llvm-py/source/browse/[http://code.google.com/p/llvm-py/source/browse]
- Issues tracker: http://code.google.com/p/llvm-py/issues/list[http://code.google.com/p/llvm-py/issues/list]
SVN HEAD can be checked out like so:
----
$ svn checkout http://llvm-py.googlecode.com/svn/trunk/ llvm-py
$ svn co http://llvm-py.googlecode.com/svn/trunk/ llvm-py
----
Mahadevan R (mdevan.foobar@gmail.com) is available to answer your
queries.
Usual caveats apply: cutting edge, may be broken (but usually not),
update and merge before sending patches etc.

View file

@ -1,7 +1,7 @@
Download
========
The latest release is 0.2.1, released 18-Jun-2008 (link:#changelog[Changelog]
The latest release is 0.3, released 8-Sep-2008 (link:#changelog[Changelog]
below).
Download it here:
@ -10,6 +10,7 @@ Download it here:
````~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Release,Date,Package,Mirror
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0.3,8-Sep-2008,http://llvm-py.googlecode.com/files/llvm-py-0.3.tar.bz2[llvm-py-0.3.tar.bz2],link:llvm-py-0.3.tar.bz2[llvm-py-0.3.tar.bz2]
0.2.1,18-Jun-2008,http://llvm-py.googlecode.com/files/llvm-py-0.2.1.tar.bz2[llvm-py-0.2.1.tar.bz2],link:llvm-py-0.2.1.tar.bz2[llvm-py-0.2.1.tar.bz2]
0.2,15-Jun-2008,http://llvm-py.googlecode.com/files/llvm-py-0.2.tar.bz2[llvm-py-0.2.tar.bz2],link:llvm-py-0.2.tar.bz2[llvm-py-0.2.tar.bz2]
0.1,20-May-2008,http://llvm-py.googlecode.com/files/llvm-py-0.1.tar.bz2[llvm-py-0.1.tar.bz2],link:llvm-py-0.1.tar.bz2[llvm-py-0.1.tar.bz2]

View file

@ -9,18 +9,24 @@ and does not use / have dependencies on "glue utilities" like
Boost.Python, swig etc.
llvm-py is just hatching. It should be stable enough to start hacking
away, though. Be sure to send in a patch (or shout at the author) if you
miss any specific LLVM API.
away, though. Be sure to send in a patch if you miss any specific LLVM
API.
_Availability_: llvm-py is available (as a source package) for LLVM 2.3
and Python 2.5. It has been built and tested on Linux/i386, and has been
reported to work with OpenBSD. It is expected to be usable on
various unices, as well as with Python 2.4 and LLVM 2.3+svn, with
minimal changes, if any.
and Python 2.5. It has been built and tested on Linux (x86, amd64) and
is reported to work with OpenBSD. It is expected to be usable on
various unices, as well as with Python 2.4.
_LLVM 2.4_: Read link:userguide.html#llvm24[this] if you're using LLVM
2.4!
News
----
8-Sep-2008::
0.3 released. Passes, intrinsics, bitcode, assembly!
18-Jun-2008::
0.2.1 released. Builds cleanly with LLVM 2.3 and 2.3+svn.

View file

@ -32,7 +32,7 @@ other unices. Windows is not supported, for a variety of reasons.
.Versions
llvm-py requires verion 2.3 of LLVM. It will not work with previous
versions.
versions. If you're using LLVM 2.4, see link:#llvm24[below].
llvm-py has been built and tested with Python 2.5. It should work with
Python 2.4, with minimal changes, if any.
@ -106,8 +106,8 @@ If you have +llvm-config+ in your path, you can build and install
llvm-py this way:
-----------------------------------------------------------------------
$ tar jxvf llvm-py-0.2.tar.bz2
$ cd llvm-py-0.2
$ tar jxvf llvm-py-0.3.tar.bz2
$ cd llvm-py-0.3
$ sudo python setup.py install
-----------------------------------------------------------------------
@ -115,8 +115,8 @@ If you need to tell the build script where +llvm-config+ is, do it this
way:
-----------------------------------------------------------------------
$ tar jxvf llvm-py-0.2.tar.bz2
$ cd llvm-py-0.2
$ tar jxvf llvm-py-0.3.tar.bz2
$ cd llvm-py-0.3
$ sudo python setup.py install --llvm-config=/home/mdevan/llvm/Release/bin/llvm-config
-----------------------------------------------------------------------
@ -124,8 +124,8 @@ To build a debug version of llvm-py, that links against the debug
libraries of LLVM, use this:
-----------------------------------------------------------------------
$ tar jxvf llvm-py-0.2.tar.bz2
$ cd llvm-py-0.2
$ tar jxvf llvm-py-0.3.tar.bz2
$ cd llvm-py-0.3
$ python setup.py build -g --llvm-config=/home/mdevan/llvm/Debug/bin/llvm-config
$ sudo python setup.py install --llvm-config=/home/mdevan/llvm/Debug/bin/llvm-config
-----------------------------------------------------------------------
@ -139,6 +139,35 @@ Python Modules] and http://docs.python.org/dist/dist.html[Distributing
Python Modules] for more information on such scripts.
[[llvm24]]
LLVM 2.4
~~~~~~~~
LLVM 2.4 is currently in progress. There are incompatible API changes
from LLVM 2.3. The latest release of llvm-py will _not_ compile against
it.
The llvm-py SVN has a branch called
http://code.google.com/p/llvm-py/source/browse/#svn/branches/llvm2.4[llvm2.4],
which attempts to track the changes happening in LLVM 2.4. There are
however, some caveats:
- There are no releases from this branch.
- When LLVM 2.4 is released, then these changes will be merged to main.
From then on llvm-py will support LLVM 2.4 and no longer LLVM 2.3.
- This branch is not religiously kept up-to-date with the changes
happening in LLVM SVN. Therefore, it may not work for you, but might
still be worth a try.
llvm-py can be checked out from this branch like this:
-----------------------------------------------------------------------
$ svn co http://llvm-py.googlecode.com/svn/branches/llvm2.4 llvm-py-2.4
-----------------------------------------------------------------------
The rest of the steps (build, install) remain the same as before.
[[uninstall]]
Uninstall
~~~~~~~~~
@ -486,6 +515,22 @@ bcfile = file("test.bc", "w")
my_module.to_bitcode(bcfile)
source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modules can also be constructed from LLVM assembly files (`.ll` files).
The static method `from_assembly` can be used for this. Similar to the
`from_bitcode` method, this one also takes a file-like object as
argument:
[python]
source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# create a module from an assembly file
llfile = file("test.ll")
my_module = Module.from_assembly(llfile)
source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modules can be converted into their assembly representation by
stringifying them (see below).
.llvm.core.Module
[caption=""]
=======================================================================
@ -496,6 +541,9 @@ source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`from_bitcode(fileobj)`::
Create a new `Module` instance by deserializing the bitcode file
represented by the file-like object `fileobj`.
`from_assembly(fileobj)`::
Create a new `Module` instance by parsing the LLVM assembly file
represented by the file-like object `fileobj`.
.Properties
`data_layout`::
@ -1467,7 +1515,7 @@ Value, Equivalent LLVM Assembly Keyword
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The corresponding
file:///home/mdevan/llvm-2.3/docs/LangRef.html#paramattrs[LLVM docs]
http://www.llvm.org/docs/LangRef.html#paramattrs[LLVM docs]
provide more information.
The alignment of any parameter can also be set via `set_argument(a)`
@ -1476,20 +1524,7 @@ where `a` is a power of 2.
Basic Block (llvm.core)
~~~~~~~~~~~~~~~~~~~~~~~
The class `llvm.core.BasicBlock` represents a basic block of
instructions. Basic blocks are logically contained within functions, and
can be constructed only via `Function` objects. Use the
`Function.append_basic_block()` method for this:
[python]
source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# create a function
func = module.add_function(functy, "fn")
# add a basic block, named 'entry', to the function
bblk = func.append_basic_block("entry")
source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The list of all
TODO
Builder (llvm.core)
@ -1501,9 +1536,6 @@ TODO
Instructions (llvm.core)
~~~~~~~~~~~~~~~~~~~~~~~~
The class `llvm.core.Instruction` represents an LLVM IR instruction.
Instruction objects can be created only via a builder.
TODO
@ -1522,13 +1554,13 @@ TODO
Execution Engine (llvm.ee)
~~~~~~~~~~~~~~~~~~~~~~~~~~
TODO
TODO. For now, see `test/example-jit.py`.
Pass Managers and Passes (llvm.passes)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TODO
TODO. For now, see `test/passes.py`.
About the llvm-py Project