pypy / pypy / jit / backend / ppc / ppcgen /

from pypy.jit.backend.ppc.ppcgen.helper.assembler import gen_emit_cmp_op
import pypy.jit.backend.ppc.ppcgen.condition as c
import pypy.jit.backend.ppc.ppcgen.register as r
from pypy.jit.backend.ppc.ppcgen.arch import GPR_SAVE_AREA, IS_PPC_32, WORD

from pypy.jit.metainterp.history import LoopToken, AbstractFailDescr

class GuardToken(object):
    def __init__(self, descr, failargs, faillocs, offset, fcond=c.NE,
                                        save_exc=False, is_invalidate=False):
        self.descr = descr
        self.offset = offset
        self.is_invalidate = is_invalidate
        self.failargs = failargs
        self.faillocs = faillocs
        self.save_exc = save_exc

class OpAssembler(object):
    # ********************************************************
    # *               I N T    O P E R A T I O N S           *
    # ********************************************************

    def emit_int_add(self, op, arglocs, regalloc):
        l0, l1, res = arglocs
        if l0.is_imm():
  , l1.value, l0.value)
        elif l1.is_imm():
  , l0.value, l1.value)
  , l0.value, l1.value)

    def emit_int_sub(self, op, arglocs, regalloc):
        l0, l1, res = arglocs
        if l0.is_imm():
  , l0.value)
  , r.r0.value, l1.value)
        elif l1.is_imm():
  , l0.value, l1.value)
  , l0.value, l1.value)
    def emit_int_mul(self, op, arglocs, regalloc):
        reg1, reg2, res = arglocs, reg1.value, reg2.value)

    def emit_int_floordiv(self, op, arglocs, regalloc):
        l0, l1, res = arglocs
        if IS_PPC_32:
            div =
            div =

        if l0.is_imm():
  , l0.value)
            div(res.value, r.r0.value, l1.value)
        elif l1.is_imm():
  , l1.value)
            div(res.value, l0.value, r.r0.value)
  , l0.value, l1.value)

    emit_int_le = gen_emit_cmp_op(c.LE)   

    def _emit_guard(self, op, arglocs, fcond, save_exc=False,
        descr = op.getdescr()
        assert isinstance(descr, AbstractFailDescr)
        pos =     # has to be patched later on

    def emit_guard_true(self, op, arglocs, regalloc):
        l0 = arglocs[0]
        failargs = arglocs[1:], 0)
        self._emit_guard(op, failargs, c.EQ)
        #                        #      ^^^^ If this condition is met,
        #                        #           then the guard fails.

    def emit_finish(self, op, arglocs, regalloc):
        self.gen_exit_stub(op.getdescr(), op.getarglist(), arglocs)

    def emit_jump(self, op, arglocs, regalloc):
        descr = op.getdescr()
        assert isinstance(descr, LoopToken)
        if descr._ppc_bootstrap_code == 0:
            curpos =
   - curpos)
            assert 0, "case not implemented yet"

    def nop(self):, 0, 0)

    def branch_abs(self, address):
        self.load_imm(r.r0.value, address)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.