[pypy-svn] pypy arm-backend-2: create a context manager to manage pushing and popping registers around calls

bivab commits-noreply at bitbucket.org
Wed Mar 30 17:31:36 CEST 2011


Author: David Schneider <david.schneider at picle.org>
Branch: arm-backend-2
Changeset: r43021:09c7c416d3af
Date: 2011-03-30 17:27 +0200
http://bitbucket.org/pypy/pypy/changeset/09c7c416d3af/

Log:	create a context manager to manage pushing and popping registers
	around calls

diff --git a/pypy/jit/backend/arm/helper/assembler.py b/pypy/jit/backend/arm/helper/assembler.py
--- a/pypy/jit/backend/arm/helper/assembler.py
+++ b/pypy/jit/backend/arm/helper/assembler.py
@@ -1,3 +1,4 @@
+from __future__ import with_statement
 from pypy.jit.backend.arm import conditions as c
 from pypy.jit.backend.arm import registers as r
 from pypy.jit.backend.arm.codebuilder import AbstractARMv7Builder
@@ -55,3 +56,14 @@
         self.mc.MOV_ri(res.value, 0, cond=inv)
         return fcond
     return f
+
+class saved_registers(object):
+    def __init__(self, assembler, regs_to_save):
+        self.assembler = assembler
+        self.regs = regs_to_save
+
+    def __enter__(self):
+        self.assembler.PUSH([r.value for r in self.regs])
+
+    def __exit__(self, *args):
+        self.assembler.POP([r.value for r in self.regs])


More information about the Pypy-commit mailing list