[pypy-commit] pypy conditional_call_value_4: PPC support for cond_call_value
arigo
pypy.commits at gmail.com
Wed Nov 23 12:33:21 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: conditional_call_value_4
Changeset: r88585:09b115d2a587
Date: 2016-11-23 18:30 +0100
http://bitbucket.org/pypy/pypy/changeset/09b115d2a587/
Log: PPC support for cond_call_value
diff --git a/rpython/jit/backend/ppc/opassembler.py b/rpython/jit/backend/ppc/opassembler.py
--- a/rpython/jit/backend/ppc/opassembler.py
+++ b/rpython/jit/backend/ppc/opassembler.py
@@ -656,10 +656,12 @@
_COND_CALL_SAVE_REGS = [r.r3, r.r4, r.r5, r.r6, r.r12]
def emit_cond_call(self, op, arglocs, regalloc):
+ resloc = arglocs[0]
+ arglocs = arglocs[1:]
+
fcond = self.guard_success_cc
self.guard_success_cc = c.cond_none
assert fcond != c.cond_none
- fcond = c.negate(fcond)
jmp_adr = self.mc.get_relative_pos()
self.mc.trap() # patched later to a 'bc'
@@ -691,7 +693,10 @@
cond_call_adr = self.cond_call_slowpath[floats * 2 + callee_only]
self.mc.bl_abs(cond_call_adr)
# restoring the registers saved above, and doing pop_gcmap(), is left
- # to the cond_call_slowpath helper. We never have any result value.
+ # to the cond_call_slowpath helper. If we have a result, move
+ # it from r2 to its expected location.
+ if resloc is not None:
+ self.mc.mr(resloc.value, r.SCRATCH2.value)
relative_target = self.mc.currpos() - jmp_adr
pmc = OverwritingBuilder(self.mc, jmp_adr, 1)
BI, BO = c.encoding[fcond]
@@ -701,6 +706,9 @@
# guard_no_exception too
self.previous_cond_call_jcond = jmp_adr, BI, BO
+ emit_cond_call_value_i = emit_cond_call
+ emit_cond_call_value_r = emit_cond_call
+
class FieldOpAssembler(object):
diff --git a/rpython/jit/backend/ppc/ppc_assembler.py b/rpython/jit/backend/ppc/ppc_assembler.py
--- a/rpython/jit/backend/ppc/ppc_assembler.py
+++ b/rpython/jit/backend/ppc/ppc_assembler.py
@@ -315,6 +315,7 @@
# * r2 is the gcmap
# * the old value of these regs must already be stored in the jitframe
# * on exit, all registers are restored from the jitframe
+ # * the result of the call, if any, is moved to r2
mc = PPCBuilder()
self.mc = mc
@@ -347,7 +348,11 @@
# Finish
self._reload_frame_if_necessary(mc)
+ # Move the result, if any, to r2
+ mc.mr(r.SCRATCH2.value, r.r3.value)
+
mc.mtlr(r.RCS1.value) # restore LR
+
self._pop_core_regs_from_jitframe(mc, saved_regs)
if supports_floats:
self._pop_fp_regs_from_jitframe(mc)
diff --git a/rpython/jit/backend/ppc/regalloc.py b/rpython/jit/backend/ppc/regalloc.py
--- a/rpython/jit/backend/ppc/regalloc.py
+++ b/rpython/jit/backend/ppc/regalloc.py
@@ -1038,14 +1038,34 @@
def prepare_cond_call(self, op):
self.load_condition_into_cc(op.getarg(0))
- locs = []
+ self.assembler.guard_success_cc = c.negate(
+ self.assembler.guard_success_cc)
+ # ^^^ if arg0==0, we jump over the next block of code (the call)
+ locs = [None]
# support between 0 and 4 integer arguments
assert 2 <= op.numargs() <= 2 + 4
for i in range(1, op.numargs()):
loc = self.loc(op.getarg(i))
assert loc.type != FLOAT
locs.append(loc)
- return locs
+ return locs # [None, function, args...]
+
+ def prepare_cond_call_value_i(self, op):
+ x = self.ensure_reg(op.getarg(0))
+ self.load_condition_into_cc(op.getarg(0))
+ self.rm.force_allocate_reg(op, selected_reg=x) # spilled if survives
+ # ^^^ if arg0!=0, we jump over the next block of code (the call)
+ locs = [x]
+ # support between 0 and 4 integer arguments
+ assert 2 <= op.numargs() <= 2 + 4
+ for i in range(1, op.numargs()):
+ loc = self.loc(op.getarg(i))
+ assert loc.type != FLOAT
+ locs.append(loc)
+ return locs # [res, function, args...]
+
+ prepare_cond_call_value_r = prepare_cond_call_value_i
+
def notimplemented(self, op):
msg = '[PPC/regalloc] %s not implemented\n' % op.getopname()
More information about the pypy-commit
mailing list