[pypy-svn] r12313 - pypy/dist/pypy/translator/llvm
cfbolz at codespeak.net
cfbolz at codespeak.net
Sun May 15 19:02:00 CEST 2005
Author: cfbolz
Date: Sun May 15 19:02:00 2005
New Revision: 12313
Modified:
pypy/dist/pypy/translator/llvm/build_llvm_module.py
pypy/dist/pypy/translator/llvm/classrepr.py
pypy/dist/pypy/translator/llvm/funcrepr.py
pypy/dist/pypy/translator/llvm/genllvm.py
pypy/dist/pypy/translator/llvm/intlist.c
pypy/dist/pypy/translator/llvm/list.c
pypy/dist/pypy/translator/llvm/llvmbc.py
pypy/dist/pypy/translator/llvm/make_runtime.py
pypy/dist/pypy/translator/llvm/memorylayout.py
pypy/dist/pypy/translator/llvm/pbcrepr.py
pypy/dist/pypy/translator/llvm/representation.py
pypy/dist/pypy/translator/llvm/seqrepr.py
pypy/dist/pypy/translator/llvm/typerepr.py
Log:
Fixed exceptions in genllvm. Added a short doc string to every file.
Modified: pypy/dist/pypy/translator/llvm/build_llvm_module.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/build_llvm_module.py (original)
+++ pypy/dist/pypy/translator/llvm/build_llvm_module.py Sun May 15 19:02:00 2005
@@ -1,5 +1,5 @@
"""
-Build a pyrex module out of llvmfile
+Build a Python module out of llvmfile and a Pyrex wrapper file.
"""
import autopath
Modified: pypy/dist/pypy/translator/llvm/classrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/classrepr.py (original)
+++ pypy/dist/pypy/translator/llvm/classrepr.py Sun May 15 19:02:00 2005
@@ -1,3 +1,8 @@
+"""
+The representations of classes and Exceptions live here. Classes are
+implemented as structs.
+"""
+
import autopath
import sets
Modified: pypy/dist/pypy/translator/llvm/funcrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/funcrepr.py (original)
+++ pypy/dist/pypy/translator/llvm/funcrepr.py Sun May 15 19:02:00 2005
@@ -1,3 +1,7 @@
+"""
+The representations of Functions/Methods/Builtin Functions.
+"""
+
import autopath
import sets, inspect
@@ -10,7 +14,9 @@
from pypy.translator.llvm import llvmbc
from pypy.translator.unsimplify import remove_double_links
-from pypy.translator.llvm.representation import debug, LLVMRepr, CompileError, last_exception, last_exc_value
+from pypy.translator.llvm.representation import debug, LLVMRepr, CompileError
+from pypy.translator.llvm.representation import last_exception, last_exc_value
+from pypy.translator.llvm.representation import SimpleRepr
from pypy.translator.llvm.typerepr import TypeRepr, PointerTypeRepr
debug = False
@@ -348,8 +354,8 @@
pass
def create_terminator_instr(self):
- l_exc = self.gen.get_repr(self.pyblock.inputargs[0])
- l_val = self.gen.get_repr(self.pyblock.inputargs[1])
+ l_exc = self.l_args[0]
+ l_val = self.l_args[1]
l_last_exception = self.gen.get_repr(last_exception)
l_last_exc_value = self.gen.get_repr(last_exc_value)
self.l_func.dependencies.update([l_exc, l_val, l_last_exception,
@@ -381,7 +387,13 @@
self.link = link
self.l_func = l_func
self.gen = gen
- self.l_args = [self.gen.get_repr(a) for a in self.link.args]
+ if link.exitcase == Exception:
+ self.l_args = [SimpleRepr("%std.class**",
+ "%std.last_exception.type", gen),
+ SimpleRepr("%std.exception**",
+ "%std.last_exception.value", gen)]
+ else:
+ self.l_args = [self.gen.get_repr(a) for a in self.link.args]
self.l_targetargs = [self.gen.get_repr(a)
for a in self.link.target.inputargs]
self.l_func.dependencies.update(self.l_args)
Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py Sun May 15 19:02:00 2005
@@ -1,5 +1,14 @@
"""
-Generate a llvm .ll file from an annotated flowgraph.
+This is the entry point of genllvm. This file can also be used with python -i
+to interactively test genllvm.
+
+The class LLVMGenerator coordinates the creation of LLVM representations and
+drives the creation of the .ll file and the compilation:
+The methods get_repr loops over all Repr classes and calls there static get
+method. If this method returns None, it continues searching, else it returns
+the object. It caches representations so that only one is generated for a given
+object.
+
"""
import autopath
Modified: pypy/dist/pypy/translator/llvm/intlist.c
==============================================================================
--- pypy/dist/pypy/translator/llvm/intlist.c (original)
+++ pypy/dist/pypy/translator/llvm/intlist.c Sun May 15 19:02:00 2005
@@ -1,3 +1,5 @@
+/* implementation of range. This file is transformed to int_list.ll by
+make_runtime.py */
#include <stdio.h>
struct list_int {
Modified: pypy/dist/pypy/translator/llvm/list.c
==============================================================================
--- pypy/dist/pypy/translator/llvm/list.c (original)
+++ pypy/dist/pypy/translator/llvm/list.c Sun May 15 19:02:00 2005
@@ -1,3 +1,5 @@
+/* implementation of list methods. This file is transformed to list_template.ll
+ by make_runtime.py */
#include <stdio.h>
signed char unwind();
Modified: pypy/dist/pypy/translator/llvm/llvmbc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/llvmbc.py (original)
+++ pypy/dist/pypy/translator/llvm/llvmbc.py Sun May 15 19:02:00 2005
@@ -1,5 +1,6 @@
"""
-Some simple classes that output LLVM-assembler.
+Some simple classes that output LLVM-assembler. Most functions here take
+subclases of LLVMRepr as arguments.
"""
import autopath
Modified: pypy/dist/pypy/translator/llvm/make_runtime.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/make_runtime.py (original)
+++ pypy/dist/pypy/translator/llvm/make_runtime.py Sun May 15 19:02:00 2005
@@ -1,3 +1,9 @@
+"""
+This file produces the .ll files with the implementations of lists and the
+implementations of simple space operations (like add, mul, sub, div for float,
+bool, int).
+"""
+
import autopath
import os
Modified: pypy/dist/pypy/translator/llvm/memorylayout.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/memorylayout.py (original)
+++ pypy/dist/pypy/translator/llvm/memorylayout.py Sun May 15 19:02:00 2005
@@ -1,3 +1,8 @@
+"""
+The MemoryLayout class helps with the layouting structs in memory.
+"""
+
+
import autopath
import sets
@@ -8,6 +13,8 @@
debug = False
+#XXX This is all mostly experimental
+
class MemoryLayout(object):
def __init__(self, attrs, l_types, gen):
self.attrs = attrs
Modified: pypy/dist/pypy/translator/llvm/pbcrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/pbcrepr.py (original)
+++ pypy/dist/pypy/translator/llvm/pbcrepr.py Sun May 15 19:02:00 2005
@@ -1,3 +1,8 @@
+"""
+The representations of prebuilt constants. This implementation is still rather
+limited.
+"""
+
import autopath
import sets
Modified: pypy/dist/pypy/translator/llvm/representation.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/representation.py (original)
+++ pypy/dist/pypy/translator/llvm/representation.py Sun May 15 19:02:00 2005
@@ -1,9 +1,27 @@
+"""
+LLVMRepr is the base class for all LLVM representations of nearly any Python
+object. A representation knows the name and type of an object in LLVM. It is
+responsible for generating the neccessary global definitions and functions the
+objects needs to be represented in LLVM.
+
+Each representation has a set of dependencies. The LLVMGenerator makes sure
+that the definitions of an object the represenation depends on are written to
+the file first.
+
+All the representation classes define a static ``get`` method. It should return
+an appropriate representation of the object if it can be represented by the
+class and None if not.
+
+Most representations are generated by calling the LLVMGenerators get_repr
+method. Thus the representation classes do not need to know anything about each
+other.
+"""
import autopath
import sets
from pypy.objspace.flow.model import Variable, Constant
-# xxx tweak just so that unrelated tests can work
-from pypy.objspace.flow.model import last_exception # this one is only used for the exitswitch now!!!
+from pypy.objspace.flow.model import last_exception
+# this is only used as a token for the pointer to the last exception object
last_exc_value = object()
from pypy.annotation import model as annmodel
Modified: pypy/dist/pypy/translator/llvm/seqrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/seqrepr.py (original)
+++ pypy/dist/pypy/translator/llvm/seqrepr.py Sun May 15 19:02:00 2005
@@ -1,3 +1,7 @@
+"""
+The representations of lists and tuples.
+"""
+
import autopath
import sets
Modified: pypy/dist/pypy/translator/llvm/typerepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/typerepr.py (original)
+++ pypy/dist/pypy/translator/llvm/typerepr.py Sun May 15 19:02:00 2005
@@ -1,3 +1,8 @@
+"""
+The representations of objects that can be the type of other objects.
+"""
+
+
import autopath
import sets
More information about the Pypy-commit
mailing list