Author: David Schneider <[email protected]>
Branch:
Changeset: r63857:807dc54ee576
Date: 2013-05-05 13:46 +0200
http://bitbucket.org/pypy/pypy/changeset/807dc54ee576/
Log: expose the supports_FEATURE flags from the jit backends as a list in
the applevel __pypy__ module
diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -85,3 +85,7 @@
from rpython.jit.backend import detect_cpu
model = detect_cpu.autodetect_main_model_and_size()
self.extra_interpdef('cpumodel', 'space.wrap(%r)' % model)
+ if self.space.config.translation.jit:
+ features = detect_cpu.getcpufeatures(model)
+ self.extra_interpdef('jit_backend_features',
+ 'space.wrap(%r)' % features)
diff --git a/pypy/module/__pypy__/test/test_special.py
b/pypy/module/__pypy__/test/test_special.py
--- a/pypy/module/__pypy__/test/test_special.py
+++ b/pypy/module/__pypy__/test/test_special.py
@@ -62,3 +62,14 @@
assert list_strategy(l) == "empty"
o = 5
raises(TypeError, list_strategy, 5)
+
+
+class AppTestJitFeatures(object):
+ spaceconfig = {"translation.jit": True}
+
+ def test_jit_backend_features(self):
+ from __pypy__ import jit_backend_features
+ supported_types = jit_backend_features
+ assert isinstance(supported_types, list)
+ for x in supported_types:
+ assert x in ['floats', 'singlefloats', 'longlong']
diff --git a/rpython/jit/backend/detect_cpu.py
b/rpython/jit/backend/detect_cpu.py
--- a/rpython/jit/backend/detect_cpu.py
+++ b/rpython/jit/backend/detect_cpu.py
@@ -115,6 +115,13 @@
mod = __import__(modname, {}, {}, clsname)
return getattr(mod, clsname)
+
+def getcpufeatures(backend_name="auto"):
+ """NOT_RPYTHON"""
+ cpucls = getcpuclass(backend_name)
+ return [attr[len('supports_'):] for attr in dir(cpucls)
+ if attr.startswith('supports_')]
+
if __name__ == '__main__':
print autodetect()
print getcpuclassname()
diff --git a/rpython/jit/backend/test/test_detect_cpu.py
b/rpython/jit/backend/test/test_detect_cpu.py
--- a/rpython/jit/backend/test/test_detect_cpu.py
+++ b/rpython/jit/backend/test/test_detect_cpu.py
@@ -31,3 +31,9 @@
def test_detect_main_model_and_size_from_platform():
info = autodetect_main_model_and_size()
assert detect_main_model_and_size_from_platform() == info
+
+def test_getcpufeatures():
+ features = getcpufeatures()
+ assert isinstance(features, list)
+ for x in features:
+ assert x in ['floats', 'singlefloats', 'longlong']
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit