Commits

David Schneider committed e13d8ab

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

Comments (0)

Files changed (2)

pypy/jit/backend/arm/test/test_runner.py

 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
 
 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)]

pypy/jit/backend/arm/tool/objdump.py

     ./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():