Merge branch 'docs-fixes' of github.com:pfalcon/llvmpy into _pr57
This commit is contained in:
commit
cada51e297
26 changed files with 163 additions and 18 deletions
|
|
@ -11,12 +11,22 @@
|
|||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
import sys, os, glob
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
#sys.path.insert(0, os.path.abspath('../..'))
|
||||
|
||||
# Support sphinx.ext.autodoc to extract docstrings from modules without installing
|
||||
# complete package.
|
||||
# The python modules depend on _core, so we must build entire package first though.
|
||||
built_lib = glob.glob('../../build/lib.*/')
|
||||
if not built_lib:
|
||||
print "WARNING: To build complete documentation you must build package first"
|
||||
else:
|
||||
# lib dir has platform suffix
|
||||
sys.path.insert(0, os.path.abspath(built_lib[0]))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
A More Complicated Function
|
||||
====================
|
||||
===========================
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
|||
Shawabkeh <http://max99x.com>`_
|
||||
|
||||
Introduction
|
||||
=========
|
||||
============
|
||||
|
||||
Welcome to the "Implementing a language with LLVM" tutorial. This
|
||||
tutorial runs through the implementation of a simple language, showing
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ variables is a useful thing regardless of whether you will be mutating
|
|||
them. Here's a motivating example that shows how we could use these:
|
||||
|
||||
|
||||
.. code-block::
|
||||
.. code-block:: none
|
||||
|
||||
# Define ':' for sequencing: as a low-precedence operator that ignores operands
|
||||
# and just returns the RHS.
|
||||
|
|
@ -352,7 +352,7 @@ function that ensures that the allocas are created in the entry block of
|
|||
the function:
|
||||
|
||||
|
||||
.. code-block::
|
||||
.. code-block:: python
|
||||
|
||||
# Creates an alloca instruction in the entry block of the function. This is used
|
||||
# for mutable variables.
|
||||
|
|
@ -475,7 +475,7 @@ It is interesting to see what the code looks like before and after the
|
|||
mem2reg optimization runs. For example, this is the before/after code
|
||||
for our recursive fib function. Before the optimization:
|
||||
|
||||
.. code-block::
|
||||
.. code-block:: llvm
|
||||
|
||||
define double @fib(double %x) {
|
||||
entry:
|
||||
|
|
@ -515,7 +515,7 @@ still just make the PHI.
|
|||
|
||||
Here is the code after the mem2reg pass runs:
|
||||
|
||||
.. code-block::
|
||||
.. code-block:: llvm
|
||||
|
||||
define double @fib(double %x) {
|
||||
entry:
|
||||
|
|
@ -651,7 +651,7 @@ Now that we have an assignment operator, we can mutate loop variables
|
|||
and arguments. For example, we can now run code like this:
|
||||
|
||||
|
||||
.. code-block::
|
||||
.. code-block:: none
|
||||
|
||||
# Function to print a double.
|
||||
extern printd(x)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
*************************************************
|
||||
***************************************************
|
||||
Chapter 8: Conclusion and other useful LLVM tidbits
|
||||
*************************************************
|
||||
***************************************************
|
||||
|
||||
Written by Chris Lattner
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ generating LLVM IR. These are some of the more subtle things that may not be obv
|
|||
but are very useful if you want to take advantage of LLVM's capabilities.
|
||||
|
||||
Properties of the LLVM IR
|
||||
========================
|
||||
=========================
|
||||
|
||||
We have a couple common questions about code in the LLVM IR form - let's
|
||||
just get these out of the way right now, shall we?
|
||||
|
|
@ -164,7 +164,7 @@ This can make sense for specialized domains such as an in-kernel language.
|
|||
--------------
|
||||
|
||||
Safety Guarantees
|
||||
----------------
|
||||
-----------------
|
||||
|
||||
Many of the languages above are also "safe" languages: it is
|
||||
impossible for a program written in Java to corrupt its address space and
|
||||
|
|
@ -236,7 +236,7 @@ you desire in your front-end, on the language-specific AST.
|
|||
--------------
|
||||
|
||||
Tips and Tricks
|
||||
==============
|
||||
===============
|
||||
|
||||
There is a variety of useful tips and tricks that you come to
|
||||
know after working on/with LLVM that aren't obvious at first glance.
|
||||
|
|
|
|||
|
|
@ -56,3 +56,10 @@ Add an attribute ``attr`` to the argument, from the set listed above.
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Remove the attribute ``attr`` of the argument.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.Argument
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -28,3 +28,10 @@ A ``Type`` object representing the type of the element of the array.
|
|||
[read-only]
|
||||
|
||||
The number of elements in the array.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.ArrayType
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -42,3 +42,10 @@ The parent function of this basicblock.
|
|||
~~~~~~~~~~~~~~~~
|
||||
|
||||
A list of instructions in this basicblock.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.BasicBlock
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -409,3 +409,10 @@ positioned.
|
|||
~~~~~~~~~
|
||||
|
||||
Deprecated. Same as ``basic_block``
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.Builder
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
| title: Constant (llvm.core) |
|
||||
+-------------------------------+
|
||||
|
||||
llvm.core.Constant
|
||||
==================
|
||||
|
||||
``Constant``-s represents constants that appear within the code. The
|
||||
values of such objects are known at creation time. Constants can be
|
||||
created from Python constants. A constant expression is also a constant
|
||||
|
|
@ -351,3 +354,9 @@ some examples:
|
|||
|
||||
assert isinstance(k1, ConstantInt) assert isinstance(k2, ConstantArray)
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.Constant
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -149,3 +149,10 @@ function bodies.
|
|||
|
||||
Verifies the function. See `LLVM
|
||||
docs <http://llvm.org/docs/Passes.html#verify>`_.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.Function
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -46,3 +46,10 @@ the function. Used like this:
|
|||
Type.int(), Type.int() ] ) for arg in func_type.args: assert arg.kind
|
||||
== TYPE_INTEGER assert arg == Type.int() assert func_type.arg_count
|
||||
== len(func_type.args)
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.FunctionType
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -95,3 +95,9 @@ A power-of-2 integer indicating the boundary to align to.
|
|||
|
||||
The module object to which this global belongs to.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.GlobalValue
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
| title: GlobalVariable (llvm.core) |
|
||||
+-------------------------------------+
|
||||
|
||||
llvm.core.GlobalVariable
|
||||
========================
|
||||
|
||||
Global variables (``llvm.core.GlobalVariable``) are subclasses of
|
||||
`llvm.core.GlobalValue <llvm.core.GlobalValue.html>`_ and represent
|
||||
module-level variables. These can have optional initializers and can be
|
||||
|
|
@ -37,3 +40,10 @@ class, or by using the static method ``GlobalVariable.new``.
|
|||
# list all global variables in a module
|
||||
for gv in module_obj.global_variables: print gv.name, "of type",
|
||||
gv.type
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.GlobalVariable
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -240,3 +240,10 @@ Properties
|
|||
|
||||
The predicate of the compare instruction, one of the ``ICMP_*`` or
|
||||
``FCMP_*`` constants.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.Instruction
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -21,3 +21,10 @@ Properties
|
|||
[read-only]
|
||||
|
||||
The width of the integer type, in number of bits.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.IntegerType
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -4,16 +4,26 @@
|
|||
| title: Module (llvm.core) |
|
||||
+-----------------------------+
|
||||
|
||||
llvm.core.Module
|
||||
================
|
||||
|
||||
Modules are top-level container objects. You need to create a module
|
||||
object first, before you can add global variables, aliases or functions.
|
||||
Modules are created using the static method ``Module.new``:
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
#!/usr/bin/env python
|
||||
|
||||
from llvm import \* from llvm.core import \*
|
||||
from llvm import *
|
||||
from llvm.core import *
|
||||
|
||||
# create a module
|
||||
my_module = Module.new('my_module')
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.Module
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -29,3 +29,10 @@ The address space of the pointer.
|
|||
|
||||
A `Type <llvm.core.Type.html>`_ object representing the type of the
|
||||
value pointed to.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.PointerType
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
llvm.core.StructType
|
||||
====================
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.StructType
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
@ -126,3 +126,10 @@ Example:
|
|||
|
||||
assert Type.int().kind == TYPE_INTEGER assert
|
||||
Type.void().kind == TYPE_VOID
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.Type
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -37,3 +37,10 @@ The list of operands (values, of type
|
|||
|
||||
The number of operands that this value referes to. Same as
|
||||
``len(uses.operands)`` but faster if you just want the count.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.User
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -63,3 +63,10 @@ representation.
|
|||
``Value`` objects can be compared for equality. Internally, this
|
||||
converts both arguments into their LLVM assembly representations and
|
||||
compares the resultant strings.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.Value
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -29,3 +29,10 @@ element of the vector.
|
|||
[read-only]
|
||||
|
||||
The number of elements in the vector.
|
||||
|
||||
|
||||
Automatically Generated Documentation
|
||||
-------------------------------------
|
||||
.. autoclass:: llvm.core.VectorType
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
llvm_cbuilder
|
||||
=========
|
||||
=============
|
||||
|
||||
llvm_cbuilder is a set of Python-contexts you can use to write C-like
|
||||
constructs in Python which generates llvmpy code directly.
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ follow these steps:
|
|||
- add a *basic block* to the function
|
||||
- using a helper object called an *instruction builder*, add two
|
||||
instructions into the basic block:
|
||||
|
||||
- an instruction to add the two
|
||||
arguments and store the result into a temporary variable
|
||||
- a return
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
contain the root `toctree` directive.
|
||||
|
||||
Documentation for llvmpy
|
||||
=================
|
||||
========================
|
||||
|
||||
Contents:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue