[pypy-commit] pypy arm-backend-2: add a viecode module in jit/backend/tool that detects and imports the

bivab noreply at buildbot.pypy.org
Fri Feb 3 12:33:51 CET 2012


Author: David Schneider <david.schneider at picle.org>
Branch: arm-backend-2
Changeset: r52069:c8e4776519d5
Date: 2012-02-03 12:15 +0100
http://bitbucket.org/pypy/pypy/changeset/c8e4776519d5/

Log:	add a viecode module in jit/backend/tool that detects and imports
	the functionality (for now machine_code_dump) from the backend
	corresponding to the current machine

diff --git a/pypy/jit/backend/arm/test/test_runner.py b/pypy/jit/backend/arm/test/test_runner.py
--- a/pypy/jit/backend/arm/test/test_runner.py
+++ b/pypy/jit/backend/arm/test/test_runner.py
@@ -30,10 +30,6 @@
     add_loop_instructions = ['mov', 'adds', 'cmp', 'beq', 'b']
     bridge_loop_instructions = ['movw', 'movt', 'bx']
 
-    def get_machine_code_dump_func(self):
-        from pypy.jit.backend.arm.tool.objdump import machine_code_dump
-        return machine_code_dump
-
     def setup_method(self, meth):
         self.cpu = ArmCPU(rtyper=None, stats=FakeStats())
         self.cpu.setup_once()
diff --git a/pypy/jit/backend/test/runner_test.py b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -3219,7 +3219,7 @@
         from pypy.jit.backend.llsupport.llmodel import AbstractLLCPU
         if not isinstance(self.cpu, AbstractLLCPU):
             py.test.skip("pointless test on non-asm")
-        machine_code_dump = self.get_machine_code_dump_func()
+        from pypy.jit.backend.tool.viewcode import machine_code_dump
         import ctypes
         ops = """
         [i3, i2]
diff --git a/pypy/jit/backend/tool/__init__.py b/pypy/jit/backend/tool/__init__.py
new file mode 100644
diff --git a/pypy/jit/backend/tool/viewcode.py b/pypy/jit/backend/tool/viewcode.py
new file mode 100644
--- /dev/null
+++ b/pypy/jit/backend/tool/viewcode.py
@@ -0,0 +1,11 @@
+from pypy.jit.backend.detect_cpu import autodetect_main_model
+import sys
+
+
+def get_module(mod):
+    __import__(mod)
+    return sys.modules[mod]
+
+cpu = autodetect_main_model()
+viewcode = get_module("pypy.jit.backend.%s.tool.viewcode" % cpu)
+machine_code_dump = getattr(viewcode, 'machine_code_dump')
diff --git a/pypy/jit/backend/x86/test/test_runner.py b/pypy/jit/backend/x86/test/test_runner.py
--- a/pypy/jit/backend/x86/test/test_runner.py
+++ b/pypy/jit/backend/x86/test/test_runner.py
@@ -40,10 +40,6 @@
         # the 'mov' is part of the 'jmp' so far
         bridge_loop_instructions = ['lea', 'mov', 'jmp']
 
-    def get_machine_code_dump_func(self):
-        from pypy.jit.backend.x86.tool.viewcode import machine_code_dump
-        return machine_code_dump
-
     def setup_method(self, meth):
         self.cpu = CPU(rtyper=None, stats=FakeStats())
         self.cpu.setup_once()
diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -95,7 +95,7 @@
         return loop
                     
     def _asm_disassemble(self, d, origin_addr, tp):
-        from pypy.jit.backend.x86.tool.viewcode import machine_code_dump
+        from pypy.jit.backend.tool.viewcode import machine_code_dump
         return list(machine_code_dump(d, tp, origin_addr))
 
     @classmethod


More information about the pypy-commit mailing list