[pypy-svn] r39808 - in pypy/dist/pypy: config translator translator/llvm translator/llvm/test
mwh at codespeak.net
mwh at codespeak.net
Sat Mar 3 15:31:09 CET 2007
Author: mwh
Date: Sat Mar 3 15:31:06 2007
New Revision: 39808
Modified:
pypy/dist/pypy/config/translationoption.py
pypy/dist/pypy/translator/driver.py
pypy/dist/pypy/translator/llvm/genllvm.py
pypy/dist/pypy/translator/llvm/opwriter.py
pypy/dist/pypy/translator/llvm/test/runtest.py
Log:
(mwh, rxe)
Make the llvm tests use the driver machinery to run the tests.
Add a few llvm-translation specific options.
Some associated insanity reduction.
Modified: pypy/dist/pypy/config/translationoption.py
==============================================================================
--- pypy/dist/pypy/config/translationoption.py (original)
+++ pypy/dist/pypy/config/translationoption.py Sat Mar 3 15:31:06 2007
@@ -167,6 +167,12 @@
('translation.backendopt.constfold', False)])
]),
+ OptionDescription("llvm", "GenLLVM options", [
+ BoolOption("debug", "Include the llops in the source as comments", default=False),
+ BoolOption("logging", "Log how long the various parts of llvm generation take", default=False),
+ BoolOption("isolate", "Peform an isolated import", default=True),
+ ]),
+
OptionDescription("cli", "GenCLI options", [
BoolOption("trace_calls", "Trace function calls", default=False,
cmdline="--cli-trace-calls")
Modified: pypy/dist/pypy/translator/driver.py
==============================================================================
--- pypy/dist/pypy/translator/driver.py (original)
+++ pypy/dist/pypy/translator/driver.py Sat Mar 3 15:31:06 2007
@@ -490,7 +490,7 @@
self.c_entryp = gen.compile_llvm_source(exe_name=exe_name)
self.create_exe()
else:
- _, self.c_entryp = gen.compile_llvm_source()
+ self.c_module, self.c_entryp = gen.compile_llvm_source()
#
task_compile_llvm = taskdef(task_compile_llvm,
['source_llvm'],
Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py Sat Mar 3 15:31:06 2007
@@ -23,8 +23,7 @@
# see create_codewriter() below
function_count = {}
- def __init__(self, translator, standalone,
- debug=True, logging=True, stackless=False):
+ def __init__(self, translator, standalone):
# reset counters
LLVMNode.nodename_count = {}
@@ -33,13 +32,6 @@
self.translator = translator
self.config = translator.config
- self.stackless = stackless
-
- # the debug flag is for creating comments of every operation that may be executed
- self.debug = debug
-
- # the logging flag is for logging information statistics in the build process
- self.logging = logging
self.source_generated = False
@@ -70,7 +62,7 @@
# XXX please dont ask!
from pypy.translator.c.genc import CStandaloneBuilder
cbuild = CStandaloneBuilder(self.translator, func, config=self.config)
- cbuild.stackless = self.stackless
+ #cbuild.stackless = self.stackless
c_db = cbuild.generate_graphs_for_llinterp()
self.db = Database(self, self.translator)
@@ -229,13 +221,12 @@
codewriter.ret("sbyte*", "null")
codewriter.closefunc()
- def compile_llvm_source(self, optimize=True, exe_name=None, isolate=False):
+ def compile_llvm_source(self, optimize=True, exe_name=None):
assert self.source_generated
assert hasattr(self, "filename")
if exe_name is not None:
assert self.standalone
- assert not isolate
return buildllvm.make_module_from_llvm(self, self.filename,
optimize=optimize,
exe_name=exe_name)
@@ -251,11 +242,11 @@
pyxfile=pyxfile,
optimize=optimize)
- mod, wrap_fun = self.get_module(isolate=isolate, *info)
+ mod, wrap_fun = self.get_module(*info)
return mod, wrap_fun
- def get_module(self, modname, dirpath, isolate=False):
- if isolate:
+ def get_module(self, modname, dirpath):
+ if self.config.translation.llvm.isolate:
mod = Isolate((dirpath, modname))
else:
from pypy.translator.tool.cbuild import import_module_from_directory
@@ -265,7 +256,7 @@
return mod, wrap_fun
def _checkpoint(self, msg=None):
- if not self.logging:
+ if not self.config.translation.llvm.logging:
return
if msg:
t = (time.time() - self.starttime)
@@ -276,7 +267,7 @@
def _print_node_stats(self):
# disable node stats output
- if not self.logging:
+ if not self.config.translation.llvm.logging:
return
nodecount = {}
Modified: pypy/dist/pypy/translator/llvm/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/opwriter.py (original)
+++ pypy/dist/pypy/translator/llvm/opwriter.py Sat Mar 3 15:31:06 2007
@@ -130,7 +130,7 @@
raise Exception, "operation %s not found" % op.opname
# XXX bit unclean
- if self.db.genllvm.debug:
+ if self.db.genllvm.config.translation.llvm.debug:
self.codewriter.comment(str(op))
meth(opr)
Modified: pypy/dist/pypy/translator/llvm/test/runtest.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/runtest.py (original)
+++ pypy/dist/pypy/translator/llvm/test/runtest.py Sat Mar 3 15:31:06 2007
@@ -34,13 +34,10 @@
def llvm_test():
if not llvm_is_on_path():
py.test.skip("could not find one of llvm-as or llvm-gcc")
- return False
llvm_ver = llvm_version()
if llvm_ver < MINIMUM_LLVM_VERSION:
py.test.skip("llvm version not up-to-date (found "
"%.1f, should be >= %.1f)" % (llvm_ver, MINIMUM_LLVM_VERSION))
- return False
- return True
def gcc3_test():
gcc_ver = gcc_version()
@@ -57,73 +54,57 @@
# debug options
debug=True,
logging=False,
- log_source=False,
+ isolate=True,
# pass to compile
optimize=True,
- **kwds):
+ extra_opts={}):
""" helper for genllvm """
- assert llvm_is_on_path()
-
- # annotate/rtype
- from pypy.translator.translator import TranslationContext
- from pypy.translator.backendopt.all import backend_optimizations
+ from pypy.translator.driver import TranslationDriver
from pypy.config.pypyoption import get_pypy_config
- config = get_pypy_config(translating=True)
- config.translation.gc = 'boehm'
- translator = TranslationContext(config=config)
- translator.buildannotator().build_types(function, annotation)
- translator.buildrtyper().specialize()
-
- # use backend optimizations?
- if optimize:
- backend_optimizations(translator, raisingop2direct_call=True)
- else:
- backend_optimizations(translator,
- raisingop2direct_call=True,
- inline_threshold=0,
- mallocs=False,
- merge_if_blocks=False,
- constfold=False)
-
- # note: this is without stackless and policy transforms
+ config = get_pypy_config({}, translating=True)
+ options = {
+ 'translation.backend': 'llvm',
+ 'translation.llvm.debug': debug,
+ 'translation.llvm.logging': logging,
+ 'translation.llvm.isolate': isolate,
+ 'translation.backendopt.none': not optimize,
+ 'translation.gc': 'boehm',
+ }
+ options.update(extra_opts)
+ config.set(**options)
+ driver = TranslationDriver(config=config)
+ driver.setup(function, annotation)
+ driver.annotate()
if conftest.option.view:
translator.view()
-
- # create genllvm
- standalone = False
- gen = GenLLVM(translator,
- standalone,
- debug=debug,
- logging=logging)
-
- filename = gen.gen_llvm_source(function)
-
- log_source = kwds.pop("log_source", False)
- if log_source:
- log(open(filename).read())
-
- return gen.compile_llvm_source(optimize=optimize, **kwds)
+ driver.rtype()
+ if conftest.option.view:
+ translator.view()
+ driver.compile()
+ if conftest.option.view:
+ translator.view()
+ return driver.c_module, driver.c_entryp
def compile_test(function, annotation, isolate=True, **kwds):
" returns module and compiled function "
- if llvm_test():
- if run_isolated_only and not isolate:
- py.test.skip("skipping not isolated test")
-
- # turn off isolation?
- isolate = isolate and not do_not_isolate
-
- # maintain only 3 isolated process (if any)
- _cleanup(leave=3)
- optimize = kwds.pop('optimize', optimize_tests)
- mod, fn = genllvm_compile(function, annotation, optimize=optimize,
- isolate=isolate, **kwds)
- if isolate:
- ext_modules.append(mod)
- return mod, fn
+ llvm_test()
+ if run_isolated_only and not isolate:
+ py.test.skip("skipping not isolated test")
+
+ # turn off isolation?
+ isolate = isolate and not do_not_isolate
+
+ # maintain only 3 isolated process (if any)
+ _cleanup(leave=3)
+ optimize = kwds.pop('optimize', optimize_tests)
+ mod, fn = genllvm_compile(function, annotation, optimize=optimize,
+ isolate=isolate, **kwds)
+ if isolate:
+ ext_modules.append(mod)
+ return mod, fn
def compile_function(function, annotation, isolate=True, **kwds):
" returns compiled function "
More information about the Pypy-commit
mailing list