*********************** The llvmpy Package *********************** 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. Out of the 6 modules, one is an "extension" module (i.e., it is written in C), and another one is a small private utility module, which leaves 4 public modules. These are: - *llvm* -- top-level package, common classes (like exceptions) - *llvm.core* -- IR-related APIs - *llvm.ee* -- execution engine related APIs - *llvm.passes* -- pass manager and passes related APIs The modules contain only classes and (integer) constants. Mostly simple Python constructs are used (deliberately) -- `property() `_ and `property decorators `_ are probably the most exotic animals around. All classes are "new style" classes. The APIs are designed to be navigable (and guessable!) once you know a few conventions. These conventions are highlighted in the sections below. Here is a quick overview of the contents of each package: llvm ---- - LLVMException -- exception class (currently the only one) llvm.core --------- - `Module `_ -- represents an LLVM Module - `Type `_ -- represents an LLVM Type - `Value `_ -- represents an LLVM Value, including: globals, constants, variables, arguments, functions, instructions, etc.. - `BasicBlock `_ -- another derived of Value, represents an LLVM basic block - `Builder `_ -- used for creating instructions, wraps LLVM IRBuilder helper class - constants *TYPE\_\** that represents various types - constants *CC\_\** that represent calling conventions - constants *ICMP\_\** and *FCMP\_\** that represent integer and real comparison predicates (like less than, greater than etc.) - constants *LINKAGE\_\** that represent linkage of symbols (external, internal etc.) - constants *VISIBILITY\_\** that represents visibility of symbols (default, hidden, protected) - constants *ATTR\_\** that represent function parameter attributes llvm.ee ------- - `ExecutionEngine `_ -- represents an execution engine (which can be an either an interpreter or a JIT) - `TargetData `_ -- represents the ABI of the target platform (details like sizes and alignment of primitive types, endinanness etc) llvm.passes ----------- - `PassManager `_ -- represents an LLVM pass manager - `FunctionPassManager `_ -- represents an LLVM function pass manager - constants *PASS\_\** that represent various passes 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 llvmpy modules thus: .. code-block:: python from llvm import * from llvm.core import * from llvm.ee import * from llvm.passes import *