PageRenderTime 81ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/rpython/jit/backend/ppc/runner.py

https://bitbucket.org/pypy/pypy/
Python | 91 lines | 58 code | 18 blank | 15 comment | 2 complexity | a35cda6751fbd8adbf9218ba3221beb0 MD5 | raw file
Possible License(s): AGPL-3.0, BSD-3-Clause, Apache-2.0
  1. from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
  2. from rpython.rtyper.llinterp import LLInterpreter
  3. from rpython.rlib import rgc
  4. from rpython.rlib.jit_hooks import LOOP_RUN_CONTAINER
  5. from rpython.jit.backend.llsupport.llmodel import AbstractLLCPU
  6. from rpython.jit.backend.ppc.ppc_assembler import AssemblerPPC
  7. from rpython.jit.backend.ppc.arch import WORD
  8. from rpython.jit.backend.ppc.codebuilder import PPCBuilder
  9. from rpython.jit.backend.ppc import register as r
  10. class PPC_CPU(AbstractLLCPU):
  11. supports_floats = True
  12. # missing: supports_singlefloats
  13. IS_64_BIT = True
  14. backend_name = 'ppc64'
  15. # can an ISA instruction handle a factor to the offset?
  16. load_supported_factors = (1,)
  17. from rpython.jit.backend.ppc.register import JITFRAME_FIXED_SIZE
  18. frame_reg = r.SP
  19. all_reg_indexes = [-1] * 32
  20. for _i, _r in enumerate(r.MANAGED_REGS):
  21. all_reg_indexes[_r.value] = _i
  22. gen_regs = r.MANAGED_REGS
  23. float_regs = [None] + r.MANAGED_FP_REGS
  24. # ^^^^ we leave a never-used hole for f0 in the jitframe
  25. # for rebuild_faillocs_from_descr(), as a counter-workaround
  26. # for the reverse hack in ALL_REG_INDEXES
  27. def __init__(self, rtyper, stats, opts=None, translate_support_code=False,
  28. gcdescr=None):
  29. AbstractLLCPU.__init__(self, rtyper, stats, opts,
  30. translate_support_code, gcdescr)
  31. def setup(self):
  32. self.assembler = AssemblerPPC(self)
  33. @rgc.no_release_gil
  34. def setup_once(self):
  35. self.assembler.setup_once()
  36. @rgc.no_release_gil
  37. def finish_once(self):
  38. self.assembler.finish_once()
  39. def compile_bridge(self, faildescr, inputargs, operations,
  40. original_loop_token, log=True, logger=None):
  41. clt = original_loop_token.compiled_loop_token
  42. clt.compiling_a_bridge()
  43. return self.assembler.assemble_bridge(faildescr, inputargs, operations,
  44. original_loop_token, log, logger)
  45. def cast_ptr_to_int(x):
  46. adr = llmemory.cast_ptr_to_adr(x)
  47. return PPC_CPU.cast_adr_to_int(adr)
  48. cast_ptr_to_int._annspecialcase_ = 'specialize:arglltype(0)'
  49. cast_ptr_to_int = staticmethod(cast_ptr_to_int)
  50. def redirect_call_assembler(self, oldlooptoken, newlooptoken):
  51. self.assembler.redirect_call_assembler(oldlooptoken, newlooptoken)
  52. def invalidate_loop(self, looptoken):
  53. """Activate all GUARD_NOT_INVALIDATED in the loop and its attached
  54. bridges. Before this call, all GUARD_NOT_INVALIDATED do nothing;
  55. after this call, they all fail. Note that afterwards, if one such
  56. guard fails often enough, it has a bridge attached to it; it is
  57. possible then to re-call invalidate_loop() on the same looptoken,
  58. which must invalidate all newer GUARD_NOT_INVALIDATED, but not the
  59. old one that already has a bridge attached to it."""
  60. for jmp, tgt in looptoken.compiled_loop_token.invalidate_positions:
  61. mc = PPCBuilder()
  62. mc.b_offset(tgt) # a single instruction
  63. mc.copy_to_raw_memory(jmp)
  64. # positions invalidated
  65. looptoken.compiled_loop_token.invalidate_positions = []
  66. def get_all_loop_runs(self):
  67. # not implemented
  68. return lltype.malloc(LOOP_RUN_CONTAINER, 0)
  69. def build_regalloc(self):
  70. ''' for tests'''
  71. from rpython.jit.backend.ppc.regalloc import Regalloc
  72. assert self.assembler is not None
  73. return Regalloc(self.assembler)