[pypy-commit] pypy arm-backend-2: Add methods and attributes required for test_compile_asmlen in the ARM test clases

bivab noreply at buildbot.pypy.org
Thu Jan 26 10:45:22 CET 2012


Author: David Schneider <david.schneider at picle.org>
Branch: arm-backend-2
Changeset: r51778:e13d8ab613df
Date: 2012-01-23 17:07 +0100
http://bitbucket.org/pypy/pypy/changeset/e13d8ab613df/

Log:	Add methods and attributes required for test_compile_asmlen in the
	ARM test clases

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
@@ -1,5 +1,6 @@
 import py
 from pypy.jit.backend.arm.runner import ArmCPU
+from pypy.jit.backend.arm.arch import WORD
 from pypy.jit.backend.test.runner_test import LLtypeBackendTest, \
                                                 boxfloat, \
                                                 constfloat
@@ -23,12 +24,20 @@
 
 class TestARM(LLtypeBackendTest):
 
+    # for the individual tests see
+    # ====> ../../test/runner_test.py
+
+    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()
 
-    # for the individual tests see
-    # ====> ../../test/runner_test.py
     def test_result_is_spilled(self):
         cpu = self.cpu
         inp = [BoxInt(i) for i in range(1, 15)]
diff --git a/pypy/jit/backend/arm/tool/objdump.py b/pypy/jit/backend/arm/tool/objdump.py
--- a/pypy/jit/backend/arm/tool/objdump.py
+++ b/pypy/jit/backend/arm/tool/objdump.py
@@ -5,9 +5,53 @@
     ./objdump.py --decode dumpfile
 """
 import os, sys, py
+import subprocess
+
+def machine_code_dump(data, originaddr, backend_name, label_list=None):
+    assert backend_name == 'arm_32'
+    tmpfile = get_tmp_file()
+    objdump = 'objdump -M reg-names-std --adjust-vma=%(origin)d -D --architecture=arm --target=binary %(file)s'
+    #
+    f = open(tmpfile, 'wb')
+    f.write(data)
+    f.close()
+    p = subprocess.Popen(objdump % {
+        'file': tmpfile,
+        'origin': originaddr,
+    }, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    stdout, stderr = p.communicate()
+    assert not p.returncode, ('Encountered an error running objdump: %s' %
+                              stderr)
+    # drop some objdump cruft
+    lines = stdout.splitlines(True)[6:]     # drop some objdump cruft
+    return format_code_dump_with_labels(originaddr, lines, label_list)
+
+def format_code_dump_with_labels(originaddr, lines, label_list):
+    from pypy.rlib.rarithmetic import r_uint
+    if not label_list:
+        label_list = []
+    originaddr = r_uint(originaddr)
+    itlines = iter(lines)
+    yield itlines.next() # don't process the first line
+    for lbl_start, lbl_name in label_list:
+        for line in itlines:
+            addr, _ = line.split(':', 1)
+            addr = int(addr, 16)
+            if addr >= originaddr+lbl_start:
+                yield '\n'
+                if lbl_name is None:
+                    yield '--end of the loop--\n'
+                else:
+                    yield str(lbl_name) + '\n'
+                yield line
+                break
+            yield line
+    # yield all the remaining lines
+    for line in itlines:
+        yield line
 
 def objdump(input):
-    os.system('objdump -D --architecture=arm --target=binary %s' % input)
+    os.system('objdump -D -M reg-names-std --architecture=arm --target=binary %s' % input)
 
 
 def get_tmp_file():


More information about the pypy-commit mailing list