diff --git a/docs/source/doc/examples.rst b/docs/source/doc/examples.rst index bbce175..98552bf 100644 --- a/docs/source/doc/examples.rst +++ b/docs/source/doc/examples.rst @@ -23,7 +23,7 @@ Here's how it looks like: {% highlight python %} #!/usr/bin/env python -Import the llvm-py modules. +Import the llvmpy modules. =========================== from llvm import \* from llvm.core import \* @@ -55,7 +55,7 @@ ty\_func = Type.function(ty\_int, [ty\_int, ty\_int]) Now we need a function named 'sum' of this type. Functions are not ================================================================== -free-standing (in llvm-py); it needs to be contained in a module. +free-standing (in llvmpy); it needs to be contained in a module. ================================================================= f\_sum = my\_module.add\_function(ty\_func, "sum") @@ -118,7 +118,7 @@ Let's compile this function in-memory and run it. {% highlight python %} #!/usr/bin/env python -Import the llvm-py modules. +Import the llvmpy modules. =========================== from llvm import \* from llvm.core import \* from llvm.ee import \* # @@ -183,7 +183,7 @@ Kaleidoscope ## {#kaleidoscope} Implementing a Language with LLVM The LLVM `Kaleidoscope `_ tutorial -has been ported to llvm-py by Max Shawabkeh. +has been ported to llvmpy by Max Shawabkeh. 1. `Tutorial Introduction and the Lexer `_ diff --git a/docs/source/doc/functions.rst b/docs/source/doc/functions.rst index 97ce73b..e56afe6 100644 --- a/docs/source/doc/functions.rst +++ b/docs/source/doc/functions.rst @@ -72,11 +72,11 @@ constants in ``llvm.core``. These are: There are also target-specific intrinsics (which correspond to that target's CPU instructions) available, but are omitted here for brevity. Full list can be seen from -[*intrinsic\_ids.py](https://github.com/numba/llvm-py/blob/master/llvm/*\ intrinsic\_ids.py). +[*intrinsic\_ids.py](https://github.com/numba/llvmpy/blob/master/llvm/*\ intrinsic\_ids.py). See the `LLVM Language Reference `_ for more information on the intrinsics, and the -`test `_ +`test `_ directory in the source distribution for more examples. The intrinsic ID can be retrieved from a function object with the read-only property ``intrinsic_id``. @@ -84,7 +84,7 @@ can be retrieved from a function object with the read-only property **Auto-generation of Intrinsic IDs** A script (tool/intrgen.py in source tree) generates the intrinsic - IDs automatically. This is necessary when compiling llvm-py with a + IDs automatically. This is necessary when compiling llvmpy with a different version of LLVM. Calling Convention # {#callconv} diff --git a/docs/source/doc/kaleidoscope/PythonLangImpl3.rst b/docs/source/doc/kaleidoscope/PythonLangImpl3.rst index 7679c8c..61594b1 100644 --- a/docs/source/doc/kaleidoscope/PythonLangImpl3.rst +++ b/docs/source/doc/kaleidoscope/PythonLangImpl3.rst @@ -29,12 +29,12 @@ will teach you a little bit about how LLVM does things, as well as demonstrate how easy it is to use. It's much more work to build a lexer and parser than it is to generate LLVM IR code. :) -**Please note**: the code in this chapter and later requires llvm-py 0.6 +**Please note**: the code in this chapter and later requires llvmpy 0.6 and LLVM 2.7. Earlier versions will most likely not work with it. Also note that you need to use a version of this tutorial that matches your -llvm-py release: If you are using an official llvm-py release, use the -version of the documentation on the `llvm-py examples -page `_ +llvmpy release: If you are using an official llvm-py release, use the +version of the documentation on the `llvmpy examples +page `_ -------------- @@ -128,7 +128,7 @@ First we'll do numeric literals: {% highlight python %} def CodeGen(self): return Constant.real(Type.double(), self.value) {% endhighlight %} -In llvm-py, floating point numeric constants are represented with the +In llvmpy, floating point numeric constants are represented with the ``llvm.core.ConstantFP`` class. To create one, we can use the static ``real()`` method in the ``llvm.core.Constant`` class. This code basically just creates and returns a ``ConstantFP``. Note that in the @@ -514,7 +514,7 @@ Full Code Listing # {#code} =========================== Here is the complete code listing for our running example, enhanced with -the LLVM code generator. Because this uses the llvm-py libraries, you +the LLVM code generator. Because this uses the llvmpy libraries, you need to `download <../download.html>`_ and `install <../userguide.html#install>`_ them. diff --git a/docs/source/doc/kaleidoscope/PythonLangImpl4.rst b/docs/source/doc/kaleidoscope/PythonLangImpl4.rst index 7aa4c85..14cefb5 100644 --- a/docs/source/doc/kaleidoscope/PythonLangImpl4.rst +++ b/docs/source/doc/kaleidoscope/PythonLangImpl4.rst @@ -329,7 +329,7 @@ Now we can load this library into the Python process using to produce simple output to the console: {% highlight python %} >>> import llvm.core >>> -llvm.core.load\_library\_permanently('/home/max/llvm-py-tutorial/putchard.so') +llvm.core.load\_library\_permanently('/home/max/llvmpy-tutorial/putchard.so') >>> import kaleidoscope >>> kaleidoscope.main() ready> extern putchard(x) Read an extern: declare double @putchard(double) diff --git a/docs/source/doc/llvm.core.Instruction.rst b/docs/source/doc/llvm.core.Instruction.rst index b03ce33..95aeb81 100644 --- a/docs/source/doc/llvm.core.Instruction.rst +++ b/docs/source/doc/llvm.core.Instruction.rst @@ -27,7 +27,7 @@ using ``operands`` property from the The name of the instruction (like ``add``, ``mul`` etc) can be got via the ``opcode_name`` property. The ``basic_block`` property gives the -basic block to which the instruction belongs to. Note that llvm-py does +basic block to which the instruction belongs to. Note that llvmpy does not allow free-standing instruction objects (i.e., all instructions are created contained within a basic block). diff --git a/docs/source/doc/llvm.core.Module.rst b/docs/source/doc/llvm.core.Module.rst index e5e2e04..19b810a 100644 --- a/docs/source/doc/llvm.core.Module.rst +++ b/docs/source/doc/llvm.core.Module.rst @@ -18,11 +18,11 @@ create a module my\_module = Module.new('my\_module') {% endhighlight %} The constructor of the Module class should *not* be used to instantiate -a Module object. This is a common feature for all llvm-py classes. +a Module object. This is a common feature for all llvmpy classes. **Convention** - *All* llvm-py objects are instantiated using static methods of + *All* llvmpy objects are instantiated using static methods of corresponding classes. Constructors *should not* be used. The argument ``my_module`` is a module identifier (a plain string). @@ -225,7 +225,7 @@ compares the resultant strings. **Convention** - *All* llvm-py objects (where it makes sense), when stringified, + *All* llvmpy objects (where it makes sense), when stringified, return the LLVM assembly representation. ``print module_obj`` for example, prints the LLVM assembly form of the entire module. diff --git a/docs/source/doc/llvm_concepts.rst b/docs/source/doc/llvm_concepts.rst index 19bdd39..a5b449b 100644 --- a/docs/source/doc/llvm_concepts.rst +++ b/docs/source/doc/llvm_concepts.rst @@ -163,7 +163,7 @@ There is an LLVM binary called `opt `_, which lets you run passes on bitcode files from the command line. You can write your own passes (in C/C++, as a shared library). This can be loaded and executed by +opt+. -(Although llvm-py does not allow you to write your own passes, it does +(Although llvmpy does not allow you to write your own passes, it does allow you to navigate the entire IR at any stage, and perform any transforms on it as you like.) @@ -211,4 +211,4 @@ multiple modules. -------------- -**Next** -- `llvm-py Package <./llvm-py_package.html>`_ +**Next** -- `llvmpy Package <./llvm-py_package.html>`_ diff --git a/docs/source/doc/llvmpy_package.rst b/docs/source/doc/llvmpy_package.rst index 8fd8a9f..1a9ad6f 100644 --- a/docs/source/doc/llvmpy_package.rst +++ b/docs/source/doc/llvmpy_package.rst @@ -1,10 +1,10 @@ +------------------------------+ | layout: page | +------------------------------+ -| title: The llvm-py Package | +| title: The llvmpy Package | +------------------------------+ -The llvm-py is a Python package, consisting of 6 modules, that wrap over +The llvmpy is a Python package, consisting of 6 modules, that wrap over enough LLVM APIs to allow the implementation of your own compiler/VM backend in pure Python. If you're come this far, you probably know why this is a good idea. @@ -80,7 +80,7 @@ A note on the importing of these modules Pythonically, modules are imported with the statement ``import llvm.core``. However, you might find it more convenient to -import llvm-py modules thus: +import llvmpy modules thus: {% highlight python %} from llvm import \* from llvm.core import \* from llvm.ee import \* from llvm.passes import \* {% endhighlight %} @@ -90,7 +90,7 @@ This avoids quite some typing. Both conventions work, however. **Tip** Python-style documentation strings (``__doc__``) are present in - llvm-py. You can use the ``help()`` of the interactive Python + llvmpy. You can use the ``help()`` of the interactive Python interpreter or the ``object?`` of `IPython `_ to get online help. (Note: not complete yet!) diff --git a/docs/source/doc/types.rst b/docs/source/doc/types.rst index 89098c7..2ca095c 100644 --- a/docs/source/doc/types.rst +++ b/docs/source/doc/types.rst @@ -6,7 +6,7 @@ Types are what you think they are. A instance of `llvm.core.Type `_, or one of its derived classes, -represent a type. llvm-py does not use as many classes to represent +represent a type. llvmpy does not use as many classes to represent types as does LLVM itself. Some types are represented using `llvm.core.Type `_ itself and the rest are represented using derived classes of diff --git a/docs/source/doc/userguide.rst b/docs/source/doc/userguide.rst index fd220e8..8b5c267 100644 --- a/docs/source/doc/userguide.rst +++ b/docs/source/doc/userguide.rst @@ -1,10 +1,8 @@ -+---------------------+ -| layout: page | -+---------------------+ -| title: User Guide | -+---------------------+ +************ +User Guide +************ -llvm-py provides Python bindings for LLVM. This document explains how +llvmpy provides Python bindings for LLVM. This document explains how you can setup and use it. A working knowledge of Python and a basic idea of LLVM is assumed. @@ -26,31 +24,31 @@ Together with `clang `_ or means to quickly instrument C and C++ sources. For e.g., llvm-gcc can be used to generate the LLVM assembly for a given C source file, which can then be loaded and manipulated (adding profiling code to every function, -say) using a llvm-py based Python script. +say) using a llvmpy based Python script. License ------- -Both LLVM and llvm-py are distributed under (different) permissive open -source licenses. llvm-py uses the `new BSD +Both LLVM and llvmpy are distributed under (different) permissive open +source licenses. llvmpy uses the `new BSD license `_. More information is available -`here `_. +`here `_. Platforms --------- -llvm-py has been built/tested/reported to work on various GNU/Linux +llvmpy has been built/tested/reported to work on various GNU/Linux flavours, BSD, Mac OS X; on i386 and amd64 architectures. Windows is not supported, for a variety of reasons. Versions -------- -llvm-py 0.8.2 requires version 3.1 of LLVM. It may not work with +llvmpy 0.8.2 requires version 3.1 of LLVM. It may not work with previous versions. -llvm-py has been built and tested with Python 2.7. It should work with +llvmpy has been built and tested with Python 2.7. It should work with earlier versions. It has not been tried with Python 3.x (patches welcome). @@ -59,7 +57,7 @@ welcome). Installation ============ -The Git repo of llvm-py is at https://github.com/numba/llvm-py.git. +The Git repo of llvmpy is at https://github.com/numba/llvmpy.git. You'll need to build and install it before it can be used. At least the following will be required for this: @@ -73,14 +71,14 @@ command ``sudo apt-get install gcc g++ python python-dev``. Ensure that your distro's repository has the appropriate version of LLVM! It does not matter which compiler LLVM itself was built with (``g++``, -``llvm-g++`` or any other); llvm-py can be built with any compiler. It +``llvm-g++`` or any other); llvmpy can be built with any compiler. It has been tried only with gcc/g++ though. LLVM and ``--enable-pic`` ------------------------- The result of an LLVM build is a set of static libraries and object -files. The llvm-py contains an extension package that is built into a +files. The llvmpy contains an extension package that is built into a shared object (\_core.so) which links to these static libraries and object files. It is therefore required that the LLVM libraries and object files be built with the ``-fPIC`` option (generate position @@ -93,14 +91,14 @@ configuring LLVM (default is no PIC), like this: llvm-config ----------- -In order to build llvm-py, it's build script needs to know from where it +In order to build llvmpy, it's build script needs to know from where it can invoke the llvm helper program, ``llvm-config``. If you've installed LLVM, then this will be available in your ``PATH``, and nothing further needs to be done. If you've built LLVM yourself, or for any reason ``llvm-config`` is not in your ``PATH``, you'll need to pass the full path of ``llvm-config`` to the build script. -You'll need to be 'root' to install llvm-py. Remember that your ``PATH`` +You'll need to be 'root' to install llvmpy. Remember that your ``PATH`` is different from that of 'root', so even if ``llvm-config`` is in your ``PATH``, it may not be available when you do ``sudo``. @@ -110,10 +108,10 @@ Steps Get 3.1 version of LLVM, build it. Make sure '--enable-pic' is passed to LLVM's 'configure'. -Get llvm-py and install it: +Get llvmpy and install it: -{% highlight bash %} $ git clone git@github.com:numba/llvm-py.git $ cd -llvm-py $ python setup.py install {% endhighlight %} +{% highlight bash %} $ git clone git@github.com:numba/llvmpy.git $ cd +llvmpy $ python setup.py install {% endhighlight %} If you need to tell the build script where ``llvm-config`` is, do it this way: @@ -122,7 +120,7 @@ this way: --llvm-config=/home/mdevan/llvm/Release/bin/llvm-config {% endhighlight %} -To build a debug version of llvm-py, that links against the debug +To build a debug version of llvmpy, that links against the debug libraries of LLVM, use this: {% highlight bash %} $ python setup.py build -g @@ -144,7 +142,7 @@ information on such scripts. Uninstall # {#uninstall} ======================== -If you'd installed llvm-py with the ``--user`` option, then llvm-py +If you'd installed llvmpy with the ``--user`` option, then llvmpy would be present under ``~/.local/lib/python2.7/site-packages``. Otherwise, it might be under ``/usr/lib/python2.7/site-packages`` or ``/usr/local/lib/python2.7/site-packages``. The directory would vary diff --git a/docs/source/index.rst b/docs/source/index.rst index aabe218..76670e6 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -3,21 +3,16 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Documenation for llvmpy +Documentation for llvmpy ================= Contents: .. toctree:: - :maxdepth: 2 + :titlesonly: doc/userguide.rst - doc/llvmpy_package.rst - doc/llvm_concepts.rst - doc/types.rst - doc/examples/JITTutorial1.rst - doc/examples/JITTutorial2.rst - doc/kaleidoscope/PythonLangImpl1.rst + doc/examples.rst Indices and tables