More documentation.
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@105 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
parent
d7839041f6
commit
ce117b2d77
10 changed files with 666 additions and 197 deletions
|
|
@ -53,7 +53,7 @@ llvm-py is distributed as a source tarball. You'll need to build and
|
|||
install it before it can be used. At least the following will be
|
||||
required for this:
|
||||
|
||||
- C and C++ compilers (gcc/g++)
|
||||
- C and C\++ compilers (gcc/g++)
|
||||
- Python itself
|
||||
- Python development files (headers and libraries)
|
||||
- LLVM, either installed or built
|
||||
|
|
@ -62,8 +62,8 @@ On debian-based systems, the first three can be installed with the
|
|||
command `sudo apt-get install gcc g++ python python-dev`. Ensure that your
|
||||
distro's respository 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 has
|
||||
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 has
|
||||
been tried only with gcc/g++ though.
|
||||
|
||||
|
||||
|
|
@ -1043,6 +1043,7 @@ a few subclasses that represent interesting instructions.
|
|||
=======================================================================
|
||||
|
||||
|
||||
[[user]]
|
||||
User (llvm.core)
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -1562,6 +1563,7 @@ should be dropped after `delete` has been called.
|
|||
Functions can be verified with the `verify` method. Note that this may
|
||||
not work properly (aborts on errors).
|
||||
|
||||
[[fnattr]]
|
||||
Function attributes, as documented
|
||||
http://www.llvm.org/docs/LangRef.html#fnattrs[here], can be
|
||||
set on functions using the methods `add_attribute` and
|
||||
|
|
@ -1684,11 +1686,13 @@ Argument (llvm.core)
|
|||
The `args` property of `llvm.core.Function` objects yields
|
||||
`llvm.core.Argument` objects. This allows for setting attributes for
|
||||
functions arguments. `Argument` objects cannot be constructed from user
|
||||
code, the only way to get a reference to these are via functions.
|
||||
code, the only way to get a reference to these are from `Function`
|
||||
objects.
|
||||
|
||||
The method `add_attribute` and `remove_attribute` can be used to add or
|
||||
remove the following attributes:
|
||||
|
||||
[[argattrs]]
|
||||
[frame="all",grid="all"]
|
||||
`25`75~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Value, Equivalent LLVM Assembly Keyword
|
||||
|
|
@ -1703,13 +1707,205 @@ Value, Equivalent LLVM Assembly Keyword
|
|||
`ATTR_NEST`, `nest`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The corresponding
|
||||
These method work exactly like the link:#fnattr[corresponding methods]
|
||||
of the `Function` class above. Refer
|
||||
http://www.llvm.org/docs/LangRef.html#paramattrs[LLVM docs]
|
||||
provide more information.
|
||||
for information on what each attribute means.
|
||||
|
||||
The alignment of any parameter can be set via the `alignment`
|
||||
The alignment of any argument can be set via the `alignment`
|
||||
property, to any power of 2.
|
||||
|
||||
.llvm.core.Argument
|
||||
[caption=""]
|
||||
=======================================================================
|
||||
.Base Class
|
||||
- `llvm.core.Value`
|
||||
|
||||
.Properties
|
||||
`alignment`::
|
||||
The alignment of the argument. Must be a power of 2.
|
||||
|
||||
.Methods
|
||||
`add_attribute(attr)`::
|
||||
Add an attribute `attr` to the argument, from the set listed above.
|
||||
`remove_attribute(attr)`::
|
||||
Remove the attribute `attr` of the argument.
|
||||
=======================================================================
|
||||
|
||||
|
||||
Instructions (llvm.core)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
An `llvm.core.Instruction` object represents an LLVM instruction. This
|
||||
class is the root of a small hierarchy:
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
Instruction
|
||||
CallOrInvokeInstruction
|
||||
PHINode
|
||||
SwitchInstruction
|
||||
CompareInstruction
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Instructions are not created directly, but via a builder. The builder
|
||||
both creates instructions and adds them to a basic block at the same
|
||||
time. One way of getting instruction objects are from basic blocks.
|
||||
|
||||
Being derived from link:#user[`llvm.core.User`], the instruction
|
||||
is-a user, i.e., an instruction in turn uses other values. The values
|
||||
an instruction uses are its operands. These may be accessed using
|
||||
`operands` property from the `llvm.core.User` base.
|
||||
|
||||
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 not allow free-standing instruction objects (i.e.,
|
||||
all instructions are created contained within a basic block).
|
||||
|
||||
Classes of instructions can be got via the properties
|
||||
`is_terminator`, `is_binary_op`, `is_shift` etc. See below for
|
||||
the full list.
|
||||
|
||||
.llvm.core.Instruction
|
||||
[caption=""]
|
||||
=======================================================================
|
||||
.Base Class
|
||||
- `llvm.core.User`
|
||||
|
||||
.Properties
|
||||
`basic_block` [read-only]::
|
||||
The basic block to which this instruction belongs to.
|
||||
`is_terminator` [read-only]::
|
||||
True if the instruction is a terminator instruction.
|
||||
`is_binary_op` [read-only]::
|
||||
True if the instruction is a binary operator.
|
||||
`is_shift` [read-only]::
|
||||
True if the instruction is a shift instruction.
|
||||
`is_cast` [read-only]::
|
||||
True if the instruction is a cast instruction.
|
||||
`is_logical_shift` [read-only]::
|
||||
True if the instruction is a logical shift instruction.
|
||||
`is_arithmetic_shift` [read-only]::
|
||||
True if the instruction is an arithmetic shift instruction.
|
||||
`is_associative` [read-only]::
|
||||
True if the instruction is associative.
|
||||
`is_commutative` [read-only]::
|
||||
True if the instruction is commutative.
|
||||
`is_volatile` [read-only]::
|
||||
True if the instruction is a volatile load or store.
|
||||
`opcode` [read-only]::
|
||||
The numeric opcode value of the instruction. Do not rely
|
||||
on the absolute value of this number, it may change with
|
||||
LLVM version.
|
||||
`opcode_name` [read-only]::
|
||||
The name of the instruction, like `add`, `sub` etc.
|
||||
=======================================================================
|
||||
|
||||
|
||||
CallOrInvokeInstruction (llvm.core)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The `llvm.core.CallOrInvokeInstruction` is a subclass of
|
||||
`llvm.core.Instruction`, and represents either a `call` or an
|
||||
`invoke` instruction.
|
||||
|
||||
.llvm.core.CallOrInvokeInstruction
|
||||
[caption=""]
|
||||
=======================================================================
|
||||
.Base Class
|
||||
- `llvm.core.Instruction`
|
||||
|
||||
.Properties
|
||||
`calling_convention`::
|
||||
Get or set the calling convention. See the link:#callconv[list above]
|
||||
for possible values.
|
||||
|
||||
.Methods
|
||||
`add_parameter_attribute(idx, attr)`::
|
||||
Add an attribute `attr` to the `idx`-th argument. See
|
||||
link:#argattrs[above] for possible values of `attr`.
|
||||
`remove_parameter_attribute(idx, attr)`::
|
||||
Remove an attribute `attr` from the `idx`-th argument. See
|
||||
link:#argattrs[above] for possible values of `attr`.
|
||||
`set_parameter_alignment(idx, align)`::
|
||||
Set the alignment of the `idx`-th argument to `align`.
|
||||
`align` should be a power of two.
|
||||
=======================================================================
|
||||
|
||||
|
||||
PHINode (llvm.core)
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The `llvm.core.PHINode` is a subclass of
|
||||
`llvm.core.Instruction`, and represents the `phi` instruction. When
|
||||
created (using `Builder.phi`) the phi node contains no incoming
|
||||
blocks (nor their corresponding values). To add an incoming arc to
|
||||
the phi node, use the `add_incoming` method, which takes a source
|
||||
block (`llvm.core.BasicBlock` object) and a value (object of
|
||||
`llvm.core.Value` or of a class derived from it) that the phi node
|
||||
will take on if control branches in from that block.
|
||||
|
||||
.llvm.core.PHINode
|
||||
[caption=""]
|
||||
=======================================================================
|
||||
.Base Class
|
||||
- `llvm.core.Instruction`
|
||||
|
||||
.Properties
|
||||
`incoming_count` [read-only]::
|
||||
The number of incoming arcs for this phi node.
|
||||
|
||||
.Methods
|
||||
`add_incoming(value, block)`::
|
||||
Add an incoming arc, from the `llvm.core.BasicBlock` object
|
||||
`block`, with the corresponding value `value`. `value` should
|
||||
be an object of `llvm.core.Value` (or of a descendent class).
|
||||
See link:#argattrs[above] for possible values of `attr`.
|
||||
`get_incoming_value(idx)`::
|
||||
Returns the `idx`-th incoming arc's value.
|
||||
`get_incoming_block(idx)`::
|
||||
Returns the `idx`-th incoming arc's block.
|
||||
=======================================================================
|
||||
|
||||
|
||||
SwitchInstruction (llvm.core)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
(TODO describe)
|
||||
|
||||
.llvm.core.SwitchInstruction
|
||||
[caption=""]
|
||||
=======================================================================
|
||||
.Base Class
|
||||
- `llvm.core.Instruction`
|
||||
|
||||
.Methods
|
||||
`add_case(const, block)`::
|
||||
Add another case to the switch statement. When the expression
|
||||
being evaluated equals `const`, then control branches to
|
||||
`block`. Here `const` must be of type `llvm.core.ConstantInt`.
|
||||
=======================================================================
|
||||
|
||||
|
||||
CompareInstruction (llvm.core)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
(TODO describe)
|
||||
|
||||
|
||||
.llvm.core.CompareInstruction
|
||||
[caption=""]
|
||||
=======================================================================
|
||||
.Base Class
|
||||
- `llvm.core.Instruction`
|
||||
|
||||
.Properties
|
||||
`predicate` [read-only]::
|
||||
The predicate of the compare instruction, one of the `ICMP_*` or
|
||||
`FCMP_*` constants.
|
||||
=======================================================================
|
||||
|
||||
|
||||
Basic Block (llvm.core)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -1722,12 +1918,6 @@ Builder (llvm.core)
|
|||
TODO
|
||||
|
||||
|
||||
Instructions (llvm.core)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
Target Data (llvm.ee)
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue