llvm-6502/bindings/python
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
..
llvm [python bindings] Added code to get the length of a memory buffer. Tests are included. 2013-09-10 06:57:57 +00:00
README.txt [llvm.py] Implement interface to object files 2012-03-10 04:41:24 +00:00

This directory contains Python bindings for LLVM's C library.

The bindings are currently a work in progress and are far from complete.
Use at your own risk.

Developer Info
==============

The single Python package is "llvm." Modules inside this package roughly
follow the names of the modules/headers defined by LLVM's C API.

Testing
-------

All test code is location in llvm/tests. Tests are written as classes
which inherit from llvm.tests.base.TestBase, which is a convenience base
class that provides common functionality.

Tests can be executed by installing nose:

    pip install nosetests

Then by running nosetests:

    nosetests

To see more output:

    nosetests -v

To step into the Python debugger while running a test, add the following
to your test at the point you wish to enter the debugger:

    import pdb; pdb.set_trace()

Then run nosetests:

    nosetests -s -v

You should strive for high code coverage. To see current coverage:

    pip install coverage
    nosetests --with-coverage --cover-html

Then open cover/index.html in your browser of choice to see the code coverage.

Style Convention
----------------

All code should pass PyFlakes. First, install PyFlakes:

    pip install pyflakes

Then at any time run it to see a report:

    pyflakes .

Eventually we'll provide a Pylint config file. In the meantime, install
Pylint:

    pip install pylint

And run:

    pylint llvm

And try to keep the number of violations to a minimum.