[pypy-commit] pypy arm-backend-2: add functions to merge unary cmp operatios with guards
bivab
noreply at buildbot.pypy.org
Tue Oct 25 16:31:55 CEST 2011
Author: David Schneider <david.schneider at picle.org>
Branch: arm-backend-2
Changeset: r48439:3c00e205750e
Date: 2011-10-25 16:31 +0200
http://bitbucket.org/pypy/pypy/changeset/3c00e205750e/
Log: add functions to merge unary cmp operatios with guards
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
@@ -17,6 +17,21 @@
f.__name__ = 'emit_op_%s' % name
return f
+def gen_emit_guard_unary_cmp(name, true_cond, false_cond):
+ def f(self, op, guard, arglocs, regalloc, fcond):
+ assert fcond is not None
+ assert guard is not None
+ reg = arglocs[0]
+ self.mc.CMP_ri(reg.value, 0)
+ cond = true_cond
+ guard_opnum = guard.getopnum()
+ if guard_opnum == rop.GUARD_FALSE:
+ cond = false_cond
+ self._emit_guard(guard, arglocs[1:], cond)
+ return fcond
+ f.__name__ = 'emit_guard_%s' % name
+ return f
+
def gen_emit_op_ri(name, opname):
ri_op = getattr(AbstractARMv7Builder, '%s_ri' % opname)
rr_op = getattr(AbstractARMv7Builder, '%s_rr' % opname)
@@ -77,7 +92,6 @@
self._emit_guard(guard, arglocs[2:], cond)
return fcond
f.__name__ = 'emit_guard_%s' % name
- f.__name__ = 'emit_op_%s' % name
return f
def gen_emit_float_op(name, opname):
@@ -86,6 +100,7 @@
arg1, arg2, result = arglocs
op_rr(self.mc, result.value, arg1.value, arg2.value)
return fcond
+ f.__name__ = 'emit_op_%s' % name
return f
def gen_emit_unary_float_op(name, opname):
op_rr = getattr(AbstractARMv7Builder, opname)
diff --git a/pypy/jit/backend/arm/helper/regalloc.py b/pypy/jit/backend/arm/helper/regalloc.py
--- a/pypy/jit/backend/arm/helper/regalloc.py
+++ b/pypy/jit/backend/arm/helper/regalloc.py
@@ -15,18 +15,6 @@
return i <= size and lower_bound
return False
-def prepare_op_unary_cmp(name=None):
- def f(self, op, fcond):
- assert fcond is not None
- a0 = op.getarg(0)
- reg, box = self._ensure_value_is_boxed(a0)
- res = self.force_allocate_reg(op.result, [box])
- self.possibly_free_vars([a0, box, op.result])
- return [reg, res]
- if name:
- f.__name__ = name
- return f
-
def prepare_op_ri(name=None, imm_size=0xFF, commutative=True, allow_zero=True):
def f(self, op, fcond):
assert fcond is not None
@@ -146,3 +134,20 @@
if name:
f.__name__ = name
return f
+
+def prepare_op_unary_cmp(name=None):
+ def f(self, op, guard_op, fcond):
+ assert fcond is not None
+ a0 = op.getarg(0)
+ reg, box = self._ensure_value_is_boxed(a0)
+ if guard_op is None:
+ res = self.force_allocate_reg(op.result, [box])
+ self.possibly_free_vars([a0, box, op.result])
+ return [reg, res]
+ else:
+ args = self._prepare_guard(guard_op, [reg])
+ self.possibly_free_vars(guard_op.getfailargs())
+ return args
+ if name:
+ f.__name__ = name
+ return f
diff --git a/pypy/jit/backend/arm/opassembler.py b/pypy/jit/backend/arm/opassembler.py
--- a/pypy/jit/backend/arm/opassembler.py
+++ b/pypy/jit/backend/arm/opassembler.py
@@ -173,6 +173,9 @@
emit_op_int_is_true = gen_emit_op_unary_cmp('int_is_true', c.NE, c.EQ)
emit_op_int_is_zero = gen_emit_op_unary_cmp('int_is_zero', c.EQ, c.NE)
+ emit_guard_int_is_true = gen_emit_guard_unary_cmp('int_is_true', c.NE, c.EQ)
+ emit_guard_int_is_zero = gen_emit_guard_unary_cmp('int_is_zero', c.EQ, c.NE)
+
def emit_op_int_invert(self, op, arglocs, regalloc, fcond):
reg, res = arglocs
diff --git a/pypy/jit/backend/arm/regalloc.py b/pypy/jit/backend/arm/regalloc.py
--- a/pypy/jit/backend/arm/regalloc.py
+++ b/pypy/jit/backend/arm/regalloc.py
@@ -451,6 +451,9 @@
prepare_op_int_is_true = prepare_op_unary_cmp('int_is_true')
prepare_op_int_is_zero = prepare_op_unary_cmp('int_is_zero')
+ prepare_guard_int_is_true = prepare_op_unary_cmp('int_is_true')
+ prepare_guard_int_is_zero = prepare_op_unary_cmp('int_is_zero')
+
def prepare_op_int_neg(self, op, fcond):
l0, box = self._ensure_value_is_boxed(op.getarg(0))
self.possibly_free_var(box)
More information about the pypy-commit
mailing list