[pypy-svn] r20370 - pypy/dist/pypy/translator/llvm
rxe at codespeak.net
rxe at codespeak.net
Mon Nov 28 20:07:18 CET 2005
Author: rxe
Date: Mon Nov 28 20:07:14 2005
New Revision: 20370
Modified:
pypy/dist/pypy/translator/llvm/arraynode.py
pypy/dist/pypy/translator/llvm/build_llvm_module.py
pypy/dist/pypy/translator/llvm/codewriter.py
pypy/dist/pypy/translator/llvm/gc.py
pypy/dist/pypy/translator/llvm/genllvm.py
Log:
Fairly boring changes sitting in my local checkout.
Modified: pypy/dist/pypy/translator/llvm/arraynode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/arraynode.py (original)
+++ pypy/dist/pypy/translator/llvm/arraynode.py Mon Nov 28 20:07:14 2005
@@ -69,8 +69,7 @@
self.ref = "%arraytype_Void"
def writedatatypedecl(self, codewriter):
- td = "%s = type { %s }" % (self.ref, self.db.get_machine_word())
- codewriter.append(td)
+ codewriter.typedef(self.ref, self.db.get_machine_word())
class ArrayNode(ConstantLLVMNode):
""" An arraynode. Elements can be
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 Mon Nov 28 20:07:14 2005
@@ -91,7 +91,7 @@
else:
gc_libs_path = '-static'
- cmds = ["llvm-as < %s.ll | opt %s -f -o %s.bc" % (b, OPTIMIZATION_SWITCHES, b)]
+ cmds = ["llvm-as < %s.ll | opt %s -f -o %s.bc" % (b, optimization_switches, b)]
if not use_gcc:
cmds.append("llc %s %s.bc -f -o %s.s" % (genllvm.exceptionpolicy.llc_options(), b, b))
cmds.append("as %s.s -o %s.o" % (b, b))
Modified: pypy/dist/pypy/translator/llvm/codewriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/codewriter.py (original)
+++ pypy/dist/pypy/translator/llvm/codewriter.py Mon Nov 28 20:07:14 2005
@@ -40,11 +40,14 @@
def globalinstance(self, name, typeandata):
self.append("%s = %s global %s" % (name, "internal", typeandata))
+ def typedef(self, name, elements):
+ self.append("%s = type { %s }" % (name, elements))
+
def structdef(self, name, typereprs):
- self.append("%s = type { %s }" %(name, ", ".join(typereprs)))
+ self.typedef(name, ", ".join(typereprs))
def arraydef(self, name, lentype, typerepr):
- self.append("%s = type { %s, [0 x %s] }" % (name, lentype, typerepr))
+ self.typedef(name, "%s, [0 x %s]" % (lentype, typerepr))
def funcdef(self, name, rettyperepr, argtypereprs):
self.append("%s = type %s (%s)" % (name, rettyperepr,
@@ -136,6 +139,12 @@
for s in self.genllvm.gcpolicy.malloc(targetvar, type_, size, atomic, self.word, self.uword).split('\n'):
self.indent(s)
+ def raw_getelementptr(self, targetvar, type, typevar, *indices):
+ word = self.word
+ res = "%(targetvar)s = getelementptr %(type)s %(typevar)s, " % locals()
+ res += ", ".join(["%s %s" % (t, i) for t, i in indices])
+ self.indent(res)
+
def getelementptr(self, targetvar, type, typevar, *indices):
word = self.word
res = "%(targetvar)s = getelementptr %(type)s %(typevar)s, %(word)s 0, " % locals()
Modified: pypy/dist/pypy/translator/llvm/gc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/gc.py (original)
+++ pypy/dist/pypy/translator/llvm/gc.py Mon Nov 28 20:07:14 2005
@@ -61,14 +61,14 @@
cnt = '.%d' % self.n_malloced
atomic = is_atomic and '_atomic' or ''
t = '''
-%%malloc.Size%(cnt)s = getelementptr %(type_)s* null, %(uword)s %(s)s
-%%malloc.SizeU%(cnt)s = cast %(type_)s* %%malloc.Size%(cnt)s to %(uword)s
-%%malloc.Ptr%(cnt)s = call fastcc sbyte* %%pypy_malloc%(atomic)s(%(uword)s %%malloc.SizeU%(cnt)s)
-%(targetvar)s = cast sbyte* %%malloc.Ptr%(cnt)s to %(type_)s*
+%%malloc_Size%(cnt)s = getelementptr %(type_)s* null, %(uword)s %(s)s
+%%malloc_SizeU%(cnt)s = cast %(type_)s* %%malloc_Size%(cnt)s to %(uword)s
+%%malloc_Ptr%(cnt)s = call fastcc sbyte* %%pypy_malloc%(atomic)s(%(uword)s %%malloc_SizeU%(cnt)s)
+%(targetvar)s = cast sbyte* %%malloc_Ptr%(cnt)s to %(type_)s*
''' % locals()
if is_atomic:
t += '''
-call ccc void %%llvm.memset(sbyte* %%malloc.Ptr%(cnt)s, ubyte 0, uint %%malloc.SizeU%(cnt)s, uint 0)
+call ccc void %%llvm.memset(sbyte* %%malloc_Ptr%(cnt)s, ubyte 0, uint %%malloc_SizeU%(cnt)s, uint 0)
''' % locals()
return t
Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py Mon Nov 28 20:07:14 2005
@@ -69,12 +69,6 @@
create c file for externs
create ll file for c file
create codewriter """
-
- # set up externs nodes
- self.extern_decls = setup_externs(self.db)
- self.translator.rtyper.specialize_more_blocks()
- self.db.setup_all()
- self._checkpoint('setup_all externs')
# get entry point
entry_point = self.get_entry_point(func)
@@ -85,6 +79,12 @@
self.entrynode = self.db.set_entrynode(entry_point)
self._checkpoint('setup_all all nodes')
+ # set up externs nodes
+ self.extern_decls = setup_externs(self.db)
+ self.translator.rtyper.specialize_more_blocks()
+ self.db.setup_all()
+ self._checkpoint('setup_all externs')
+
self._print_node_stats()
# create ll file from c code
More information about the Pypy-commit
mailing list