| 1 |
import rpython.jit.backend.zarch.conditions as c |
| 2 |
import rpython.jit.backend.zarch.registers as r |
| 3 |
from rpython.rlib.rarithmetic import intmask |
| 4 |
from rpython.jit.backend.zarch.arch import WORD |
| 5 |
from rpython.jit.backend.zarch.helper.regalloc import check_imm_value |
| 6 |
from rpython.jit.metainterp.history import FLOAT |
| 7 |
from rpython.jit.metainterp.resoperation import rop |
| 8 |
from rpython.rtyper.lltypesystem import rffi, lltype |
| 9 |
|
| 10 |
def do_emit_cmp_op(self, arglocs, condition, signed, fp): |
| 11 |
l0 = arglocs[0] |
| 12 |
l1 = arglocs[1] |
| 13 |
assert not l0.is_imm() |
| 14 |
|
| 15 |
self.mc.cmp_op(l0, l1, pool=l1.is_in_pool(), imm=l1.is_imm(), signed=signed, fp=fp) |
| 16 |
self.flush_cc(condition, arglocs[2]) |
| 17 |
|
| 18 |
|
| 19 |
def gen_emit_cmp_op(condition, signed=True, fp=False): |
| 20 |
def f(self, op, arglocs, regalloc): |
| 21 |
do_emit_cmp_op(self, arglocs, condition, signed, fp) |
| 22 |
return f |
| 23 |
|
| 24 |
def gen_emit_shift(func): |
| 25 |
def f(self, op, arglocs, regalloc): |
| 26 |
lr, l0, l1 = arglocs |
| 27 |
assert lr is not l0 |
| 28 |
getattr(self.mc, func)(lr, l0, l1) |
| 29 |
f.name = 'emit_shift_' + func |
| 30 |
return f |
| 31 |
|
| 32 |
def gen_emit_rr_rp(rr_func, rp_func): |
| 33 |
def f(self, op, arglocs, regalloc): |
| 34 |
l0, l1 = arglocs |
| 35 |
if l1.is_in_pool(): |
| 36 |
getattr(self.mc, rp_func)(l0, l1) |
| 37 |
else: |
| 38 |
getattr(self.mc, rr_func)(l0, l1) |
| 39 |
return f |
| 40 |
|
| 41 |
def gen_emit_rr_rh_ri_rp(rr_func, rh_func, ri_func, rp_func): |
| 42 |
def emit(self, op, arglocs, regalloc): |
| 43 |
l0, l1 = arglocs |
| 44 |
if l1.is_in_pool(): |
| 45 |
getattr(self.mc, rp_func)(l0, l1) |
| 46 |
elif l1.is_imm(): |
| 47 |
if check_imm_value(l1.value): |
| 48 |
getattr(self.mc, rh_func)(l0, l1) |
| 49 |
else: |
| 50 |
getattr(self.mc, ri_func)(l0, l1) |
| 51 |
else: |
| 52 |
getattr(self.mc, rr_func)(l0, l1) |
| 53 |
return emit |
| 54 |
|
| 55 |
def gen_emit_div_mod(rr_func, rp_func): |
| 56 |
def emit(self, op, arglocs, regalloc): |
| 57 |
lr, lq, l1 = arglocs |
| 58 |
|
| 59 |
|
| 60 |
assert not l1.is_imm(), "imm divider not supported" |
| 61 |
|
| 62 |
assert lr.is_even() |
| 63 |
assert lq.is_odd() |
| 64 |
self.mc.XGR(lr, lr) |
| 65 |
if l1.is_in_pool(): |
| 66 |
getattr(self.mc,rp_func)(lr, l1) |
| 67 |
else: |
| 68 |
getattr(self.mc,rr_func)(lr, l1) |
| 69 |
return emit |