diff --git a/llvm/__init__.py b/llvm/__init__.py index e69de29..ac0afac 100644 --- a/llvm/__init__.py +++ b/llvm/__init__.py @@ -0,0 +1,14 @@ +"""Common classes related to LLVM. + +""" + +#===----------------------------------------------------------------------=== +# Exceptions +#===----------------------------------------------------------------------=== + +class LLVMException(Exception): + + def __init__(self, msg=""): + Exception.__init__(self, msg) + + diff --git a/llvm/_core.c b/llvm/_core.c index aedcd88..c3f897a 100644 --- a/llvm/_core.c +++ b/llvm/_core.c @@ -3,6 +3,10 @@ #include "wrap.h" #include "extra.h" +/* LLVM includes */ +#include "llvm-c/Analysis.h" +#include "llvm-c/Transforms/Scalar.h" + /* libc includes */ #include /* for malloc(), free() */ @@ -600,6 +604,19 @@ _wrap_obj2obj(LLVMFinalizeFunctionPassManager, LLVMPassManagerRef, int) _wrap_obj2none(LLVMDisposePassManager, LLVMPassManagerRef) +/*===----------------------------------------------------------------------===*/ +/* Passes */ +/*===----------------------------------------------------------------------===*/ + +_wrap_obj2none(LLVMAddConstantPropagationPass, LLVMPassManagerRef) +_wrap_obj2none(LLVMAddInstructionCombiningPass, LLVMPassManagerRef) +_wrap_obj2none(LLVMAddPromoteMemoryToRegisterPass, LLVMPassManagerRef) +_wrap_obj2none(LLVMAddDemoteMemoryToRegisterPass, LLVMPassManagerRef) +_wrap_obj2none(LLVMAddReassociatePass, LLVMPassManagerRef) +_wrap_obj2none(LLVMAddGVNPass, LLVMPassManagerRef) +_wrap_obj2none(LLVMAddCFGSimplificationPass, LLVMPassManagerRef) + + /*===----------------------------------------------------------------------===*/ /* Python member method table */ /*===----------------------------------------------------------------------===*/ @@ -922,6 +939,15 @@ static PyMethodDef core_methods[] = { _method( LLVMFinalizeFunctionPassManager ) _method( LLVMDisposePassManager ) + /* Passes */ + _method( LLVMAddConstantPropagationPass ) + _method( LLVMAddInstructionCombiningPass ) + _method( LLVMAddPromoteMemoryToRegisterPass ) + _method( LLVMAddDemoteMemoryToRegisterPass ) + _method( LLVMAddReassociatePass ) + _method( LLVMAddGVNPass ) + _method( LLVMAddCFGSimplificationPass ) + { NULL } }; diff --git a/llvm/_util.py b/llvm/_util.py new file mode 100644 index 0000000..1d8704b --- /dev/null +++ b/llvm/_util.py @@ -0,0 +1,39 @@ +"""Utility functions and classes. + +Not for public use!""" + +import core + +def _check_gen(obj, type): + if not isinstance(obj, type): + msg = "argument must be an instance of llvm.core.%s (or of a class derived from it)" % type_str + raise TypeError, msg + +def check_is_type(obj): _check_gen(obj, core.Type) +def check_is_value(obj): _check_gen(obj, core.Value) +def check_is_pointer(obj): _check_gen(obj, core.Pointer) +def check_is_constant(obj): _check_gen(obj, core.Constant) +def check_is_function(obj): _check_gen(obj, core.Function) +def check_is_basic_block(obj): _check_gen(obj, core.BasicBlock) +def check_is_module_provider(obj): _check_gen(obj, core.ModuleProvider) + +def unpack_gen(objlist, check_fn): + for obj in objlist: check_fn(obj) + return [ obj.ptr for obj in objlist ] + +def unpack_types(objlist): return unpack_gen(objlist, check_is_type) +def unpack_values(objlist): return unpack_gen(objlist, check_is_value) +def unpack_constants(objlist): return unpack_gen(objlist, check_is_constant) + +def wrapiter(first, next, container, wrapper): + ptr = first(container) + while ptr: + yield wrapper(ptr) + ptr = next(ptr) + +class dummy_owner(object): + + def __init__(self, ownee): + ownee._own(self) + + diff --git a/llvm/core.py b/llvm/core.py index 149a227..ebfc722 100644 --- a/llvm/core.py +++ b/llvm/core.py @@ -4,7 +4,8 @@ The llvm.core module contains classes and constants required to build the in-memory intermediate representation (IR) data structures.""" -import _core +import llvm # top-level, for common stuff +import _core # C wrappers #===----------------------------------------------------------------------=== @@ -102,6 +103,7 @@ ATTR_READONLY = 1024 def _check_gen(obj, type, type_str): if not isinstance(obj, type): + type_str = type.__module__ + "." + type.__name__ msg = "argument must be an instance of llvm.core.%s (or of a class derived from it)" % type_str raise TypeError, msg @@ -278,7 +280,9 @@ class Module(object): _core.LLVMGetNextFunction, self.ptr, Function) def verify(self): - return _core.LLVMVerifyModule(self.ptr) + ret = _core.LLVMVerifyModule(self.ptr) + if ret != "": + raise llvm.LLVMException, ret #===----------------------------------------------------------------------=== diff --git a/llvm/ee.py b/llvm/ee.py new file mode 100644 index 0000000..918fe3a --- /dev/null +++ b/llvm/ee.py @@ -0,0 +1,51 @@ +"""Execution Engine and related classes. + +""" + +import llvm, core +from _util import * +import _core + +class ExecutionEngine(object): + + @staticmethod + def new(mp, force_interpreter=False): + check_is_module_provider(mp) + ret = _core.LLVMCreateExecutionEngine(mp.ptr, int(create_interpreter)) + if isinstance(ret, str): + raise llvm.LLVMException, str + return ExecutionEngine(ret) + + def __init__(self, ptr): + self.ptr = ptr + + def __del__(self): + _core.LLVMDisposeExecutionEngine(self.ptr) + + def run_static_constructors(self): + _core.LLVMRunStaticConstructors(self.ptr) + + def run_static_destructors(self): + _core.LLVMRunStaticDestructors(self.ptr) + + def run_function_as_main(self, fn, argv, envp): + check_is_function(fn) + _core.LLVMRunFunctionAsMain(self.ptr, fn.ptr, argv, envp) + + def run_function(self, fn, args): + check_is_function(fn) + return _core.LLVMRunFunction(self.ptr, fn.ptr, args) + + def free_machine_code_for_function(self, fn): + check_is_function(fn) + _core.LLVMFreeMachineCodeForFunction(self.ptr, fn.ptr) + + def add_module_provider(self, mp): + pass + + def remove_module_provider(self): + pass + + @property + def target_data(self): + return TargetData(_core.LLVMGetExecutionEngineTargetData(self.ptr)) diff --git a/llvm/passes.py b/llvm/passes.py new file mode 100644 index 0000000..208a788 --- /dev/null +++ b/llvm/passes.py @@ -0,0 +1,78 @@ + +from _util import * +import _core + +# passes +PASS_CONSTANT_PROPAGATION = 1 +PASS_INSTRUCTION_COMBINING = 2 +PASS_PROMOTE_MEMORY_TO_REGISTER = 3 +PASS_DEMOTE_MEMORY_TO_REGISTER = 4 +PASS_REASSOCIATE = 5 +PASS_GVN = 6 +PASS_CFG_SIMPLIFICATION = 7 + + +#===----------------------------------------------------------------------=== +# Helper functions +#===----------------------------------------------------------------------=== + +_pass_creator = { + PASS_CONSTANT_PROPAGATION : _core.LLVMAddConstantPropagationPass, + PASS_INSTRUCTION_COMBINING : _core.LLVMAddInstructionCombiningPass, + PASS_PROMOTE_MEMORY_TO_REGISTER : _core.LLVMAddPromoteMemoryToRegisterPass, + PASS_DEMOTE_MEMORY_TO_REGISTER : _core.LLVMAddDemoteMemoryToRegisterPass, + PASS_REASSOCIATE : _core.LLVMAddReassociatePass, + PASS_GVN : _core.LLVMAddGVNPass, + PASS_CFG_SIMPLIFICATION : _core.LLVMAddCFGSimplificationPass, +} + + +#===----------------------------------------------------------------------=== +# Pass manager +#===----------------------------------------------------------------------=== + +class PassManager(object): + + @staticmethod + def new(): + return PassManager(_core.LLVMCreatePassManager()) + + def __init__(self, ptr): + self.ptr = ptr + + def __del__(self): + _core.LLVMDisposePassManager(self.ptr) + + def add(self, pass_id): + assert pass_id in _pass_creator, 'Invalid pass_id ("' + str(pass_id) + '")' + cfn = _pass_creator[pass_id] # KeyError => pass_id is invalid + cfn(self.ptr) + + def run(self, module): + check_is_module(module) + return _core.LLVMRunPassManager(self.ptr, module.ptr) + + +class FunctionPassManager(PassManager): + + @staticmethod + def new(mp): + check_is_module_provider(mp) + return FunctionPassManager(_core.LLVMCreateFunctionPassManager(mp.ptr)) + + def __init__(self, ptr): + PassManager.__init__(self, ptr) + + def __del__(self): + PassManager.__del__(self) + + def initialize(self): + _core.LLVMInitializeFunctionPassManager(self.ptr) + + def run(self, fn): + _check_is_function(fn) + return _core.LLVMRunFunctionPassManager(fn.ptr) + + def finalize(self): + _core.LLVMFinalizeFunctionPassManager(self.ptr) + diff --git a/llvm/wrap.h b/llvm/wrap.h index d15bdc5..e231ef0 100644 --- a/llvm/wrap.h +++ b/llvm/wrap.h @@ -11,8 +11,8 @@ #include /* llvm includes */ -#include -#include +#include "llvm-c/Core.h" +#include "llvm-c/Analysis.h" /*===----------------------------------------------------------------------===*/ diff --git a/setup.py b/setup.py index 2706fdc..95f7d37 100644 --- a/setup.py +++ b/setup.py @@ -8,8 +8,17 @@ def _run(cmd): return os.popen(cmd).read().rstrip() -def get_libs(llvm_config, components): - return _run(llvm_config + ' --libs ' + ' '.join(components)) +def get_libs_and_objs(llvm_config, components): + parts = _run(llvm_config + ' --libs ' + ' '.join(components)).split() + libs = [] + objs = [] + for part in parts: + if part.startswith('-l'): + libs.append(part[2:]) + else: + assert part.endswith('.o') + objs.append(part[:-2]) + return (libs, objs) def get_llvm_config(): @@ -34,7 +43,9 @@ def call_setup(llvm_config): incdir = _run(llvm_config + ' --includedir') ldflags = _run(llvm_config + ' --ldflags') - libs_core = get_libs(llvm_config, ['core', 'analysis']) + libs_core, objs_core = get_libs_and_objs(llvm_config, ['core', 'analysis', 'scalaropts']) + + std_libs = [ 'pthread', 'dl', 'm' ] ext_core = Extension( 'llvm._core', @@ -43,7 +54,9 @@ def call_setup(llvm_config): ('__STDC_LIMIT_MACROS', None), ('_GNU_SOURCE', None)], include_dirs = [incdir], - extra_link_args = [ldflags + ' ' + libs_core]) + library_dirs = [ '/home/mdevan/llvm/Release/lib' ], + libraries = std_libs + libs_core, + extra_objects = objs_core) setup( name='llvm-py', diff --git a/www/makeweb.py b/www/makeweb.py new file mode 100755 index 0000000..6164edd --- /dev/null +++ b/www/makeweb.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python + +import os, sys, shutil +from stat import * +from string import Template +from optparse import OptionParser + +# files in src dir that should not be copied to web dir +SKIP_FILES = [ 'layout.conf' ] + +# asciidoc command line +ASCIIDOC = 'asciidoc --unsafe --conf-file=${srcdir}/layout.conf -a icons -o ${outfile} ${infile}' + + +def _is_older(inp, outp): + older = True + if os.path.exists(outp): + modin = os.stat(inp)[ST_MTIME] + modout = os.stat(outp)[ST_MTIME] + older = (modin > modout) + return older + + +def _rmtree_warn(fn, path, excinfo): + print "** WARNING **: error while doing %s on %s" % (fn, path) + + +def asciidoc(opts, srcdir, inp, outp): + if _is_older(inp, outp) or opts.force: + if opts.verbose: + print "asciidoc %s -> %s" % (inp, outp) + cmd = Template(ASCIIDOC).substitute(srcdir=srcdir, infile=inp, outfile=outp) + if opts.verbose >= 3: + print "asciidoc command is [%s]" % cmd + if not opts.dryrun: + os.system(cmd) + else: + if opts.verbose >= 2: + print "up to date %s -> %s" % (inp, outp) + + +def copy(opts, inp, outp): + if os.path.isdir(inp): + if os.path.exists(outp) and not os.path.isdir(outp): + print "** ERROR **: cannot copy directory ('%s') to file ('%s')" % (inp, outp) + sys.exit(1) + if not os.path.exists(outp): + if opts.verbose: + print "creating %s" % (outp) + if not opts.dryrun: + os.mkdir(outp) + for file in os.listdir(inp): + copy(opts, os.path.join(inp, file), os.path.join(outp, file)) + else: + if _is_older(inp, outp) or opts.force: + if opts.verbose: + print "copying %s -> %s" % (inp, outp) + if not opts.dryrun: + shutil.copy(inp, outp) + else: + if opts.verbose >= 2: + print "up to date %s -> %s" % (inp, outp) + + +def make(opts, indir, outdir): + # make output dir if it does not exist + if not os.path.exists(outdir): + if opts.verbose: + print "creating %s" % outdir + if not opts.dryrun: + os.mkdir(outdir) + # process all files/dirs under input directory + for elem in os.listdir(indir): + inp = os.path.join(indir, elem) + if elem.endswith('.txt'): + outp = os.path.join(outdir, elem[:-4] + '.html') + asciidoc(opts, indir, inp, outp) + elif elem not in SKIP_FILES: + outp = os.path.join(outdir, elem) + copy(opts, inp, outp) + + +def get_opts(): + usage = "usage: %prog [options] srcdir destdir" + + p = OptionParser(usage=usage) + p.add_option("-f", "--force", action="store_true", dest="force", default=False, + help="ignore timestamps and force build of all files") + p.add_option("-v", "--verbose", action="count", dest="verbose", default=0, + help="be chatty (use more v's to be more friendly)") + p.add_option("-c", "--clean-first", action="store_true", dest="clean", default=False, + help="remove outdir and everything under it before building") + p.add_option("-n", "--dry-run", action="store_true", dest="dryrun", default=False, + help="just print what will happen rather than doing it") + + (opts, args) = p.parse_args() + if len(args) != 2: + p.error("incorrect number of arguments") + srcdir, destdir = args + + if not os.path.exists(srcdir): + p.error("srcdir (%s) does not exist" % srcdir) + if not os.path.isdir(args[0]): + p.error("srcdir (%s) is not a directory" % srcdir) + if os.path.exists(destdir) and not os.path.isdir(destdir): + p.error("destdir (%s) is not a directory" % destdir) + + if opts.verbose == None: + opts.verbose = 0 + + return (opts, srcdir, destdir) + + +def main(): + opts, src, dest = get_opts() + if opts.verbose >= 3: + print ("running with options:\nsrc = [%s]\ndest = [%s]\nverbose = [%d]\n" +\ + "dry-run = [%d]\nclean-first = [%d]\nforce = [%d]") %\ + (src, dest, opts.verbose, opts.dryrun, opts.clean, opts.force) + if opts.dryrun and opts.verbose == 0: + opts.verbose = 1 + if opts.clean: + if opts.dryrun or opts.verbose: + print "removing tree %s" % dest + if not opts.dryrun: + os.rmtree(dest, True, _rmtree_warn) + make(opts, src, dest) + + +main() + diff --git a/www/src/about.txt b/www/src/about.txt new file mode 100644 index 0000000..3d073b8 --- /dev/null +++ b/www/src/about.txt @@ -0,0 +1,15 @@ +About +===== + +[NOTE] +._llvm-py_ Mission Statement +======================================================================= +Provide a simple, consistent and well-documented suite of APIs +that exposes just enough of LLVM to write a compiler/interpreter/VM +in Python. +======================================================================= + +_llvm-py_ is developed by Mahadevan R, in his spare time, without being +paid for it. He can be reached at _mdevan.foobar .at. gmail.com_, on the +llvm-dev mailing list and irc.oftc.net#llvm (mdevan). + diff --git a/www/src/contribute.txt b/www/src/contribute.txt new file mode 100644 index 0000000..93d7226 --- /dev/null +++ b/www/src/contribute.txt @@ -0,0 +1,16 @@ +Contribute +========== + +_llvm-py_ is just hatching. It needs your patches and suggestions to +grow up. Please contribute! All patches are welcome. + +The _llvm-py_ code is hosted on a google code project by the same name, +http://code.google.com/p/llvm-py/[here]. It provides the SVN repository +and a http://code.google.com/p/llvm-py/issues/list[bug tracker]. + +The latest code can be checked out from SVN like so: + +---- +$ svn checkout http://llvm-py.googlecode.com/svn/trunk/ llvm-py +---- + diff --git a/www/src/download.txt b/www/src/download.txt new file mode 100644 index 0000000..aa7c2e3 --- /dev/null +++ b/www/src/download.txt @@ -0,0 +1,82 @@ +Download and Setup +================== + +The latest release is 0.2, released xx-Jun-2008 (full link:changelog[Changelog] +below). + +Download it here: + +[frame="all",grid="all"] +````~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Release,Date,Package,Mirror +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +0.2,xx-xxx-2008,http://link1/[llvm-py-0.2.tar.bz2],http://link1/[llvm-py-0.2.tar.bz2] +0.1,xx-xxx-2008,http://link1/[llvm-py-0.1.tar.bz2],http://link1/[llvm-py-0.1.tar.bz2] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +Bleeding Edge +------------- + +The latest code can be checked out from SVN thusly: + +---- +$ svn checkout http://llvm-py.googlecode.com/svn/trunk/ llvm-py +---- + +Happy hacking, and please send in your patches. + + +Setting Up +---------- + +Follow these steps to get _llvm-py_ up and running: + +* Get and build LLVM. +* Optionally, install it. +* Get the latest release (see above) of _llvm-py_ and untar it: +---- +$ wget http://link/llvm-py-0.2.tar.bz2 +$ tar jxvf llvm-py-0.2.tar.bz2 +---- +* If you've installed LLVM, setup _llvm-py_ like this: +---- +$ cd llvm-py-0.2 +$ sudo python setup.py install +---- +* If you haven't installed LLVM, locate the executable +llvm-config+ + under your LLVM build directory (should be something like + +/home/mdevan/llvm/Release/bin/llvm-config+) and pass this to setup.py: +---- +$ cd llvm-py-0.2 +$ sudo python setup.py install --llvm-config=/path/to/llvm-config +---- + +That's it! + +NOTE: _setup.py_ is a standard Python distutils script. See the Python +documentation regarding http://docs.python.org/inst/inst.html[Installing +Python Modules] and http://docs.python.org/dist/dist.html[Distributing +Python Modules] for more information on such scripts. + +Uninstall +--------- + +To get rid of llvm-py completely, if you wish to do so: + +---- +# rm -rf /usr/lib/python2.5/site-packages/llvm +# rm -f /usr/lib/python2.5/site-packages/llvm_py-0.1.egg-info +---- + +You'll need to be root to do this. Paths are for debian-based systems, +in other distros it might be different. + + +[[changelog]] +Changelog +---------- + +---- +include::changelog[] +---- diff --git a/www/src/examples.txt b/www/src/examples.txt new file mode 100644 index 0000000..b95013d --- /dev/null +++ b/www/src/examples.txt @@ -0,0 +1,67 @@ +Examples +======== + +Here's an example: + +[python] +source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +#!/usr/bin/env python + +from llvm.core import * + +## create a module +module = Module.new("my_module") + +## create a function type taking two doubles and returning a (32-bit) integer +ty_double = Type.double() +ty_int = Type.int() +ty_func = Type.function( ty_int, [ ty_double, ty_double ] ) + +## create a function of this type +func = Function.new( module, ty_func, "foobar" ) + +# name function args +func.args[0].name = "arg1" +func.args[1].name = "arg2" + +## implement the function + +# add a basic block +entry = func.append_basic_block("entry") + +# create an llvm::IRBuilder +builder = Builder.new() +builder.position_at_end(entry) + +# add two args into temp1 +temp1 = builder.add(func.args[0], func.args[1], "temp1") + +# sub `1' from that +one = Constant.real( ty_double, 1.0 ) +temp2 = builder.sub(temp1, one, "temp2") + +# convert to integer +temp3 = builder.fptoui(temp2, ty_int, "temp3") + +# return it +builder.ret(temp3) + +# dump the module to see the bc +module.dump() +source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +which gives this output: + +----------------------------------------------------------------------- +; ModuleID = 'my_module' + +define i32 @foobar(double %arg1, double %arg2) { +entry: + %temp1 = add double %arg1, %arg2 ; [#uses=1] + %temp2 = sub double %temp1, 1.000000e+00 ; [#uses=1] + %temp3 = fptoui double %temp2 to i32 ; [#uses=1] + ret i32 %temp3 +} +----------------------------------------------------------------------- + + diff --git a/www/src/images/icons/callouts/1.png b/www/src/images/icons/callouts/1.png new file mode 100644 index 0000000..7d47343 Binary files /dev/null and b/www/src/images/icons/callouts/1.png differ diff --git a/www/src/images/icons/callouts/10.png b/www/src/images/icons/callouts/10.png new file mode 100644 index 0000000..997bbc8 Binary files /dev/null and b/www/src/images/icons/callouts/10.png differ diff --git a/www/src/images/icons/callouts/11.png b/www/src/images/icons/callouts/11.png new file mode 100644 index 0000000..ce47dac Binary files /dev/null and b/www/src/images/icons/callouts/11.png differ diff --git a/www/src/images/icons/callouts/12.png b/www/src/images/icons/callouts/12.png new file mode 100644 index 0000000..31daf4e Binary files /dev/null and b/www/src/images/icons/callouts/12.png differ diff --git a/www/src/images/icons/callouts/13.png b/www/src/images/icons/callouts/13.png new file mode 100644 index 0000000..14021a8 Binary files /dev/null and b/www/src/images/icons/callouts/13.png differ diff --git a/www/src/images/icons/callouts/14.png b/www/src/images/icons/callouts/14.png new file mode 100644 index 0000000..64014b7 Binary files /dev/null and b/www/src/images/icons/callouts/14.png differ diff --git a/www/src/images/icons/callouts/15.png b/www/src/images/icons/callouts/15.png new file mode 100644 index 0000000..0d65765 Binary files /dev/null and b/www/src/images/icons/callouts/15.png differ diff --git a/www/src/images/icons/callouts/2.png b/www/src/images/icons/callouts/2.png new file mode 100644 index 0000000..5d09341 Binary files /dev/null and b/www/src/images/icons/callouts/2.png differ diff --git a/www/src/images/icons/callouts/3.png b/www/src/images/icons/callouts/3.png new file mode 100644 index 0000000..ef7b700 Binary files /dev/null and b/www/src/images/icons/callouts/3.png differ diff --git a/www/src/images/icons/callouts/4.png b/www/src/images/icons/callouts/4.png new file mode 100644 index 0000000..adb8364 Binary files /dev/null and b/www/src/images/icons/callouts/4.png differ diff --git a/www/src/images/icons/callouts/5.png b/www/src/images/icons/callouts/5.png new file mode 100644 index 0000000..4d7eb46 Binary files /dev/null and b/www/src/images/icons/callouts/5.png differ diff --git a/www/src/images/icons/callouts/6.png b/www/src/images/icons/callouts/6.png new file mode 100644 index 0000000..0ba694a Binary files /dev/null and b/www/src/images/icons/callouts/6.png differ diff --git a/www/src/images/icons/callouts/7.png b/www/src/images/icons/callouts/7.png new file mode 100644 index 0000000..472e96f Binary files /dev/null and b/www/src/images/icons/callouts/7.png differ diff --git a/www/src/images/icons/callouts/8.png b/www/src/images/icons/callouts/8.png new file mode 100644 index 0000000..5e60973 Binary files /dev/null and b/www/src/images/icons/callouts/8.png differ diff --git a/www/src/images/icons/callouts/9.png b/www/src/images/icons/callouts/9.png new file mode 100644 index 0000000..a0676d2 Binary files /dev/null and b/www/src/images/icons/callouts/9.png differ diff --git a/www/src/images/icons/caution.png b/www/src/images/icons/caution.png new file mode 100644 index 0000000..cb9d5ea Binary files /dev/null and b/www/src/images/icons/caution.png differ diff --git a/www/src/images/icons/example.png b/www/src/images/icons/example.png new file mode 100644 index 0000000..bba1c00 Binary files /dev/null and b/www/src/images/icons/example.png differ diff --git a/www/src/images/icons/home.png b/www/src/images/icons/home.png new file mode 100644 index 0000000..37a5231 Binary files /dev/null and b/www/src/images/icons/home.png differ diff --git a/www/src/images/icons/important.png b/www/src/images/icons/important.png new file mode 100644 index 0000000..1096c23 Binary files /dev/null and b/www/src/images/icons/important.png differ diff --git a/www/src/images/icons/next.png b/www/src/images/icons/next.png new file mode 100644 index 0000000..64e126b Binary files /dev/null and b/www/src/images/icons/next.png differ diff --git a/www/src/images/icons/note.png b/www/src/images/icons/note.png new file mode 100644 index 0000000..841820f Binary files /dev/null and b/www/src/images/icons/note.png differ diff --git a/www/src/images/icons/prev.png b/www/src/images/icons/prev.png new file mode 100644 index 0000000..3e8f12f Binary files /dev/null and b/www/src/images/icons/prev.png differ diff --git a/www/src/images/icons/tip.png b/www/src/images/icons/tip.png new file mode 100644 index 0000000..a3a029d Binary files /dev/null and b/www/src/images/icons/tip.png differ diff --git a/www/src/images/icons/up.png b/www/src/images/icons/up.png new file mode 100644 index 0000000..2db1ce6 Binary files /dev/null and b/www/src/images/icons/up.png differ diff --git a/www/src/images/icons/warning.png b/www/src/images/icons/warning.png new file mode 100644 index 0000000..0b0c419 Binary files /dev/null and b/www/src/images/icons/warning.png differ diff --git a/www/src/index.txt b/www/src/index.txt new file mode 100644 index 0000000..a11a4dd --- /dev/null +++ b/www/src/index.txt @@ -0,0 +1,27 @@ +llvm-py: Python Bindings for LLVM +=================================== + +_llvm-py_ provides http://www.python.org/[Python] bindings for +http://llvm.org/[LLVM]. It currently provides APIs to build the in-memory IR +(intermediate representation) and to dump it. Execution engine and related APIs +should appear soon. + +_llvm-py_ is a set of Python-based and C-based Python modules. It makes use of +llvm-c, the C binding for LLVM. It is based on the latest SVN version of LLVM +(and will not work on 2.2). It has been tested only with Python 2.5, although +it should be usable with 2.4 also. I've built and tested it only on Linux/i386 +machines. + +Download links, setup help and changelog are on the +link:download.html[download] page. + +News +---- + +xx-Jun-2008:: + 0.2 released. Head to the link:downlad.html[download] page! + +xx-May-2008:: + 0.1 released. + +// vim: set syntax=asciidoc: diff --git a/www/src/layout.conf b/www/src/layout.conf new file mode 100644 index 0000000..f18fd08 --- /dev/null +++ b/www/src/layout.conf @@ -0,0 +1,82 @@ +# +# AsciiDoc website. +# Three division table based layout (layout1). +# +# +-----------------------------------------------------+ +# | #layout-banner | +# +--------------+--------------------------------------+ +# | | | +# | | | +# | #layout-menu | #layout-content | +# | | | +# | | | +# | | | +# +--------------+--------------------------------------+ +# +# - The #layout-menu and #layout-content divisions are contained in a +# two cell table. +# I would be nice to use pure CSS for the layout but the table is better for +# this layout because: +# +# * The column widths automatically size to fit column width (specifically +# the #layout-menu) +# * The column heights automatically size to the tallest. +# +# - The #layout-content division is a container for AsciiDoc page documents. +# - Documents rendered in the #layout-content use the standard AsciiDoc +# xhtml11 backend stylesheets. + +[specialwords] +emphasizedwords=(?u)\\?\bAsciiDoc\b +monospacedwords=(?u)\\?\basciidoc\(1\) (?u)\\?\ba2x\(1\) + +[header] + + + + + + + + + + +{doctitle} - llvm-py + + +
+
llvm-py
+
Python Bindings for LLVM
+
+ + + + + +
+ + + + + + + + + + +
+ + +[footer] + +
+
+ + diff --git a/www/src/license.txt b/www/src/license.txt new file mode 100644 index 0000000..531cee2 --- /dev/null +++ b/www/src/license.txt @@ -0,0 +1,40 @@ +License +======= + +_llvm-py_ is distributed under the +http://www.opensource.org/licenses/bsd-license.php[new BSD license]. +This is similar to LLVM's license. You should be able to use _llvm-py_ +where-ever and how-ever you're able to use LLVM itself. + +The license text is present in the +http://code.google.com/p/llvm-py/source/browse/trunk/LICENSE[LICENSE] +file in the distribution, and is reproduced here: + +---- +Copyright (c) 2008, Mahadevan R All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of the Mahadevan R, llvm-py nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +---- diff --git a/www/src/style/layout.css b/www/src/style/layout.css new file mode 100644 index 0000000..5d60b2d --- /dev/null +++ b/www/src/style/layout.css @@ -0,0 +1,71 @@ + +body { + background-color: white; + margin: 1%; +} + +h1 { + margin-top: 0.5em; +} + +#layout-banner { + background-color: #73a0c5; + color: white; + font-family: sans-serif; + text-align: left; + padding: 0.8em 20px; +} + +#layout-title { + font-family: monospace; + font-size: 3.5em; + font-weight: bold; + letter-spacing: 0.2em; + margin: 0; +} + +#layout-description { + font-size: 1.2em; + letter-spacing: 0.1em; +} + +#layout-menu { + background-color: #f4f4f4; + border-right: 3px solid #eeeeee; + padding-top: 0.8em; + padding-left: 20px; + padding-right: 0.8em; + font-size: 1.1em; + font-family: sans-serif; + font-weight: bold; +} +#layout-menu a { + line-height: 2em; + margin-left: 0.5em; +} +#layout-menu a:link, #layout-menu a:visited, #layout-menu a:hover { + color: #527bbd; + text-decoration: none; +} +#layout-menu a:hover { + color: navy; + text-decoration: none; +} +#layout-menu #page-source { + border-top: 2px solid silver; + margin-top: 0.2em; +} + +#layout-content { + margin-left: 1.0em; +} + +.para { + line-height: 1.5em; + margin-top: 1.2em; +} + +@media print { + #layout-banner { display: none; } + #layout-menu { display: none; } +} diff --git a/www/src/style/xhtml11-manpage.css b/www/src/style/xhtml11-manpage.css new file mode 100644 index 0000000..3ea378a --- /dev/null +++ b/www/src/style/xhtml11-manpage.css @@ -0,0 +1,18 @@ +/* Overrides for manpage documents */ +h1 { + padding-top: 0.5em; + padding-bottom: 0.5em; + border-top: 2px solid silver; + border-bottom: 2px solid silver; +} +h2 { + border-style: none; +} +div.sectionbody { + margin-left: 5%; +} + +@media print { + div#toc { display: none; } +} + diff --git a/www/src/style/xhtml11-quirks.css b/www/src/style/xhtml11-quirks.css new file mode 100644 index 0000000..dbb7775 --- /dev/null +++ b/www/src/style/xhtml11-quirks.css @@ -0,0 +1,40 @@ +/* Workarounds for IE6's broken and incomplete CSS2. */ + +div.sidebar-content { + background: #ffffee; + border: 1px solid silver; + padding: 0.5em; +} +div.sidebar-title, div.image-title { + color: #527bbd; + font-family: sans-serif; + font-weight: bold; + margin-top: 0.0em; + margin-bottom: 0.5em; +} + +div.listingblock div.content { + border: 1px solid silver; + background: #f4f4f4; + padding: 0.5em; +} + +div.quoteblock-content { + padding-left: 2.0em; +} + +div.exampleblock-content { + border-left: 2px solid silver; + padding-left: 0.5em; +} + +/* IE6 sets dynamically generated links as visited. */ +div#toc a:visited { color: blue; } + +/* Because IE6 child selector is broken. */ +div.olist2 ol { + list-style-type: lower-alpha; +} +div.olist2 div.olist ol { + list-style-type: decimal; +} diff --git a/www/src/style/xhtml11.css b/www/src/style/xhtml11.css new file mode 100644 index 0000000..fd931dd --- /dev/null +++ b/www/src/style/xhtml11.css @@ -0,0 +1,276 @@ +/* Debug borders */ +p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { +/* + border: 1px solid red; +*/ +} + +body { + margin: 1em 5% 1em 5%; +} + +a { + color: blue; + text-decoration: underline; +} +a:visited { + color: fuchsia; +} + +em { + font-style: italic; + color: navy; +} + +strong { + font-weight: bold; + color: #083194; +} + +tt { + color: navy; +} + +h1, h2, h3, h4, h5, h6 { + color: #527bbd; + font-family: sans-serif; + margin-top: 1.2em; + margin-bottom: 0.5em; + line-height: 1.3; +} + +h1, h2, h3 { + border-bottom: 2px solid silver; +} +h2 { + padding-top: 0.5em; +} +h3 { + float: left; +} +h3 + * { + clear: left; +} + +div.sectionbody { + font-family: serif; + margin-left: 0; +} + +hr { + border: 1px solid silver; +} + +p { + margin-top: 0.5em; + margin-bottom: 0.5em; +} + +ul, ol, li > p { + margin-top: 0; +} + +pre { + padding: 0; + margin: 0; +} + +span#author { + color: #527bbd; + font-family: sans-serif; + font-weight: bold; + font-size: 1.1em; +} +span#email { +} +span#revision { + font-family: sans-serif; +} + +div#footer { + font-family: sans-serif; + font-size: small; + border-top: 2px solid silver; + padding-top: 0.5em; + margin-top: 4.0em; +} +div#footer-text { + float: left; + padding-bottom: 0.5em; +} +div#footer-badges { + float: right; + padding-bottom: 0.5em; +} + +div#preamble, +div.tableblock, div.imageblock, div.exampleblock, div.verseblock, +div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, +div.admonitionblock { + margin-right: 10%; + margin-top: 1.5em; + margin-bottom: 1.5em; +} +div.admonitionblock { + margin-top: 2.5em; + margin-bottom: 2.5em; +} + +div.content { /* Block element content. */ + padding: 0; +} + +/* Block element titles. */ +div.title, caption.title { + color: #527bbd; + font-family: sans-serif; + font-weight: bold; + text-align: left; + margin-top: 1.0em; + margin-bottom: 0.5em; +} +div.title + * { + margin-top: 0; +} + +td div.title:first-child { + margin-top: 0.0em; +} +div.content div.title:first-child { + margin-top: 0.0em; +} +div.content + div.title { + margin-top: 0.0em; +} + +div.sidebarblock > div.content { + background: #ffffee; + border: 1px solid silver; + padding: 0.5em; +} + +div.listingblock { + margin-right: 0%; +} +div.listingblock > div.content { + border: 1px solid silver; + background: #f4f4f4; + padding: 0.5em; +} + +div.quoteblock > div.content { + padding-left: 2.0em; +} + +div.attribution { + text-align: right; +} +div.verseblock + div.attribution { + text-align: left; +} + +div.admonitionblock .icon { + vertical-align: top; + font-size: 1.1em; + font-weight: bold; + text-decoration: underline; + color: #527bbd; + padding-right: 0.5em; +} +div.admonitionblock td.content { + padding-left: 0.5em; + border-left: 2px solid silver; +} + +div.exampleblock > div.content { + border-left: 2px solid silver; + padding: 0.5em; +} + +div.verseblock div.content { + white-space: pre; +} + +div.imageblock div.content { padding-left: 0; } +div.imageblock img { border: 1px solid silver; } +span.image img { border-style: none; } + +dl { + margin-top: 0.8em; + margin-bottom: 0.8em; +} +dt { + margin-top: 0.5em; + margin-bottom: 0; + font-style: normal; +} +dd > *:first-child { + margin-top: 0.1em; +} + +ul, ol { + list-style-position: outside; +} +div.olist > ol { + list-style-type: decimal; +} +div.olist2 > ol { + list-style-type: lower-alpha; +} + +div.tableblock > table { + border: 3px solid #527bbd; +} +thead { + font-family: sans-serif; + font-weight: bold; +} +tfoot { + font-weight: bold; +} + +div.hlist { + margin-top: 0.8em; + margin-bottom: 0.8em; +} +div.hlist td { + padding-bottom: 15px; +} +td.hlist1 { + vertical-align: top; + font-style: normal; + padding-right: 0.8em; +} +td.hlist2 { + vertical-align: top; +} + +@media print { + div#footer-badges { display: none; } +} + +div#toctitle { + color: #527bbd; + font-family: sans-serif; + font-size: 1.1em; + font-weight: bold; + margin-top: 1.0em; + margin-bottom: 0.1em; +} + +div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { + margin-top: 0; + margin-bottom: 0; +} +div.toclevel2 { + margin-left: 2em; + font-size: 0.9em; +} +div.toclevel3 { + margin-left: 4em; + font-size: 0.9em; +} +div.toclevel4 { + margin-left: 6em; + font-size: 0.9em; +} diff --git a/www/src/userguide.txt b/www/src/userguide.txt new file mode 100644 index 0000000..224a402 --- /dev/null +++ b/www/src/userguide.txt @@ -0,0 +1,22 @@ +AsciiDoc User Guide +=================== +Stuart Rackham +:Author Initials: SJR + +AsciiDoc is a text document format for writing short documents, +articles, books and UNIX man pages. AsciiDoc files can be translated +to HTML and DocBook markups using the asciidoc(1) command. AsciiDoc +is highly configurable: both the AsciiDoc source file syntax and the +backend output markups (which can be almost any type of SGML/XML +markup) can be customized and extended by the user. + + +Introduction +------------ + +TIP: Sometimes incorrect highlighting is caused by preceding lines +that appear blank but contain white space characters -- setting your +editor options so that white space characters are visible is a good +idea. + +// vim: set syntax=asciidoc: