pypy / pypy / jit / backend / arm / arch.py

from pypy.rpython.lltypesystem import lltype, rffi
from pypy.rlib.rarithmetic import r_uint


FUNC_ALIGN = 8
WORD = 4
DOUBLE_WORD = 8

# the number of registers that we need to save around malloc calls
N_REGISTERS_SAVED_BY_MALLOC = 9
# the offset from the FP where the list of the registers mentioned above starts
MY_COPY_OF_REGS = WORD
# The Address in the PC points two words befind the current instruction
PC_OFFSET = 8
FORCE_INDEX_OFS = 0

from pypy.translator.tool.cbuild import ExternalCompilationInfo
eci = ExternalCompilationInfo(post_include_bits=["""
static int pypy__arm_int_div(int a, int b) {
    return a/b;
}
static uint pypy__arm_uint_div(uint a, uint b) {
    return a/b;
}
static int pypy__arm_int_mod(uint a, uint b) {
    return a % b;
}
"""])


def arm_int_div_emulator(a, b):
    return int(a / float(b))
arm_int_div_sign = lltype.Ptr(
        lltype.FuncType([lltype.Signed, lltype.Signed], lltype.Signed))
arm_int_div = rffi.llexternal(
    "pypy__arm_int_div", [lltype.Signed, lltype.Signed], lltype.Signed,
                        _callable=arm_int_div_emulator,
                        compilation_info=eci,
                        _nowrapper=True, elidable_function=True)


def arm_uint_div_emulator(a, b):
    return r_uint(a) / r_uint(b)
arm_uint_div_sign = lltype.Ptr(
        lltype.FuncType([lltype.Unsigned, lltype.Unsigned], lltype.Unsigned))
arm_uint_div = rffi.llexternal(
    "pypy__arm_uint_div", [lltype.Unsigned, lltype.Unsigned], lltype.Unsigned,
                        _callable=arm_uint_div_emulator,
                        compilation_info=eci,
                        _nowrapper=True, elidable_function=True)


def arm_int_mod_emulator(a, b):
    sign = 1
    if a < 0:
        a = -1 * a
        sign = -1
    if b < 0:
        b = -1 * b
    res = a % b
    return sign * res
arm_int_mod_sign = arm_int_div_sign
arm_int_mod = rffi.llexternal(
    "pypy__arm_int_mod", [lltype.Signed, lltype.Signed], lltype.Signed,
                        _callable=arm_int_mod_emulator,
                        compilation_info=eci,
                        _nowrapper=True, elidable_function=True)
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 ProjectModifiedEvent.java.
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.