| 1 |
from rpython.jit.backend.arm.arch import JITFRAME_FIXED_SIZE |
| 2 |
from rpython.jit.backend.arm.assembler import AssemblerARM |
| 3 |
from rpython.jit.backend.arm.regalloc import VFPRegisterManager |
| 4 |
from rpython.jit.backend.arm.registers import fp, all_regs |
| 5 |
from rpython.jit.backend.llsupport import jitframe |
| 6 |
from rpython.jit.backend.llsupport.llmodel import AbstractLLCPU |
| 7 |
from rpython.rlib.jit_hooks import LOOP_RUN_CONTAINER |
| 8 |
from rpython.rtyper.lltypesystem import lltype, llmemory |
| 9 |
from rpython.jit.backend.arm.detect import detect_hardfloat |
| 10 |
from rpython.jit.backend.arm.detect import detect_arch_version, detect_neon |
| 11 |
|
| 12 |
jitframe.STATICSIZE = JITFRAME_FIXED_SIZE |
| 13 |
|
| 14 |
class CPUInfo(object): |
| 15 |
hf_abi = False |
| 16 |
arch_version = 6 |
| 17 |
neon = False |
| 18 |
|
| 19 |
class AbstractARMCPU(AbstractLLCPU): |
| 20 |
|
| 21 |
IS_64_BIT = False |
| 22 |
|
| 23 |
supports_floats = True |
| 24 |
supports_longlong = True |
| 25 |
supports_singlefloats = True |
| 26 |
supports_load_effective_address = True |
| 27 |
|
| 28 |
from rpython.jit.backend.arm.arch import JITFRAME_FIXED_SIZE |
| 29 |
all_reg_indexes = range(len(all_regs)) |
| 30 |
gen_regs = all_regs |
| 31 |
float_regs = VFPRegisterManager.all_regs |
| 32 |
frame_reg = fp |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
load_supported_factors = (1,) |
| 37 |
|
| 38 |
def __init__(self, rtyper, stats, opts=None, translate_support_code=False, |
| 39 |
gcdescr=None): |
| 40 |
AbstractLLCPU.__init__(self, rtyper, stats, opts, |
| 41 |
translate_support_code, gcdescr) |
| 42 |
self.cpuinfo = CPUInfo() |
| 43 |
|
| 44 |
def set_debug(self, flag): |
| 45 |
return self.assembler.set_debug(flag) |
| 46 |
|
| 47 |
def setup(self): |
| 48 |
self.assembler = AssemblerARM(self, self.translate_support_code) |
| 49 |
|
| 50 |
def setup_once(self): |
| 51 |
self.cpuinfo.arch_version = detect_arch_version() |
| 52 |
self.cpuinfo.hf_abi = detect_hardfloat() |
| 53 |
self.cpuinfo.neon = detect_neon() |
| 54 |
|
| 55 |
self.assembler.setup_once() |
| 56 |
|
| 57 |
def finish_once(self): |
| 58 |
self.assembler.finish_once() |
| 59 |
|
| 60 |
def compile_bridge(self, faildescr, inputargs, operations, |
| 61 |
original_loop_token, log=True, logger=None): |
| 62 |
clt = original_loop_token.compiled_loop_token |
| 63 |
clt.compiling_a_bridge() |
| 64 |
return self.assembler.assemble_bridge(logger, faildescr, inputargs, |
| 65 |
operations, |
| 66 |
original_loop_token, log=log) |
| 67 |
|
| 68 |
def cast_ptr_to_int(x): |
| 69 |
adr = llmemory.cast_ptr_to_adr(x) |
| 70 |
return CPU_ARM.cast_adr_to_int(adr) |
| 71 |
cast_ptr_to_int._annspecialcase_ = 'specialize:arglltype(0)' |
| 72 |
cast_ptr_to_int = staticmethod(cast_ptr_to_int) |
| 73 |
|
| 74 |
def redirect_call_assembler(self, oldlooptoken, newlooptoken): |
| 75 |
self.assembler.redirect_call_assembler(oldlooptoken, newlooptoken) |
| 76 |
|
| 77 |
def invalidate_loop(self, looptoken): |
| 78 |
"""Activate all GUARD_NOT_INVALIDATED in the loop and its attached |
| 79 |
bridges. Before this call, all GUARD_NOT_INVALIDATED do nothing; |
| 80 |
after this call, they all fail. Note that afterwards, if one such |
| 81 |
guard fails often enough, it has a bridge attached to it; it is |
| 82 |
possible then to re-call invalidate_loop() on the same looptoken, |
| 83 |
which must invalidate all newer GUARD_NOT_INVALIDATED, but not the |
| 84 |
old one that already has a bridge attached to it.""" |
| 85 |
from rpython.jit.backend.arm.codebuilder import InstrBuilder |
| 86 |
|
| 87 |
for jmp, tgt in looptoken.compiled_loop_token.invalidate_positions: |
| 88 |
mc = InstrBuilder(self.cpuinfo.arch_version) |
| 89 |
mc.B_offs(tgt) |
| 90 |
mc.copy_to_raw_memory(jmp) |
| 91 |
|
| 92 |
looptoken.compiled_loop_token.invalidate_positions = [] |
| 93 |
|
| 94 |
|
| 95 |
def get_all_loop_runs(self): |
| 96 |
l = lltype.malloc(LOOP_RUN_CONTAINER, |
| 97 |
len(self.assembler.loop_run_counters)) |
| 98 |
for i, ll_s in enumerate(self.assembler.loop_run_counters): |
| 99 |
l[i].type = ll_s.type |
| 100 |
l[i].number = ll_s.number |
| 101 |
l[i].counter = ll_s.i |
| 102 |
return l |
| 103 |
|
| 104 |
def build_regalloc(self): |
| 105 |
''' for tests''' |
| 106 |
from rpython.jit.backend.arm.regalloc import Regalloc |
| 107 |
assert self.assembler is not None |
| 108 |
return Regalloc(self.assembler) |
| 109 |
|
| 110 |
|
| 111 |
class CPU_ARM(AbstractARMCPU): |
| 112 |
"""ARM""" |
| 113 |
backend_name = "arm" |