[pypy-commit] pypy default: Only execute NEON instructions on CPUs supporting NEON
stefanor
pypy.commits at gmail.com
Fri Mar 25 22:25:39 EDT 2016
Author: Stefano Rivera <stefano at rivera.za.net>
Branch:
Changeset: r83380:fc95c9347679
Date: 2016-03-25 21:24 -0500
http://bitbucket.org/pypy/pypy/changeset/fc95c9347679/
Log: Only execute NEON instructions on CPUs supporting NEON
On Debian armhf, NEON is not mandated. In fact Debian's buildds
don't support it.
diff --git a/rpython/jit/backend/arm/detect.py b/rpython/jit/backend/arm/detect.py
--- a/rpython/jit/backend/arm/detect.py
+++ b/rpython/jit/backend/arm/detect.py
@@ -1,6 +1,7 @@
import os
from rpython.translator.tool.cbuild import ExternalCompilationInfo
+from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.rtyper.tool import rffi_platform
from rpython.rlib.clibffi import FFI_DEFAULT_ABI, FFI_SYSV, FFI_VFP
from rpython.translator.platform import CompilationError
@@ -15,6 +16,7 @@
asm volatile("VMOV s0, s1");
}
"""])
+getauxval = rffi.llexternal("getauxval", [lltype.Unsigned], lltype.Unsigned)
def detect_hardfloat():
return FFI_DEFAULT_ABI == FFI_VFP
@@ -63,3 +65,10 @@
"falling back to", "ARMv%d" % n)
debug_stop("jit-backend-arch")
return n
+
+
+def detect_neon():
+ AT_HWCAP = 16
+ HWCAP_NEON = 1 << 12
+ hwcap = getauxval(AT_HWCAP)
+ return bool(hwcap & HWCAP_NEON)
diff --git a/rpython/jit/backend/arm/opassembler.py b/rpython/jit/backend/arm/opassembler.py
--- a/rpython/jit/backend/arm/opassembler.py
+++ b/rpython/jit/backend/arm/opassembler.py
@@ -1092,8 +1092,8 @@
self.mc.VCVT_int_to_float(res.value, r.svfp_ip.value)
return fcond
- # the following five instructions are only ARMv7;
- # regalloc.py won't call them at all on ARMv6
+ # the following five instructions are only ARMv7 with NEON;
+ # regalloc.py won't call them at all, in other cases
emit_opx_llong_add = gen_emit_float_op('llong_add', 'VADD_i64')
emit_opx_llong_sub = gen_emit_float_op('llong_sub', 'VSUB_i64')
emit_opx_llong_and = gen_emit_float_op('llong_and', 'VAND_i64')
diff --git a/rpython/jit/backend/arm/regalloc.py b/rpython/jit/backend/arm/regalloc.py
--- a/rpython/jit/backend/arm/regalloc.py
+++ b/rpython/jit/backend/arm/regalloc.py
@@ -530,7 +530,7 @@
EffectInfo.OS_LLONG_AND,
EffectInfo.OS_LLONG_OR,
EffectInfo.OS_LLONG_XOR):
- if self.cpu.cpuinfo.arch_version >= 7:
+ if self.cpu.cpuinfo.neon:
args = self._prepare_llong_binop_xx(op, fcond)
self.perform_extra(op, args, fcond)
return
diff --git a/rpython/jit/backend/arm/runner.py b/rpython/jit/backend/arm/runner.py
--- a/rpython/jit/backend/arm/runner.py
+++ b/rpython/jit/backend/arm/runner.py
@@ -7,13 +7,14 @@
from rpython.rlib.jit_hooks import LOOP_RUN_CONTAINER
from rpython.rtyper.lltypesystem import lltype, llmemory
from rpython.jit.backend.arm.detect import detect_hardfloat
-from rpython.jit.backend.arm.detect import detect_arch_version
+from rpython.jit.backend.arm.detect import detect_arch_version, detect_neon
jitframe.STATICSIZE = JITFRAME_FIXED_SIZE
class CPUInfo(object):
hf_abi = False
arch_version = 6
+ neon = False
class AbstractARMCPU(AbstractLLCPU):
@@ -48,6 +49,7 @@
def setup_once(self):
self.cpuinfo.arch_version = detect_arch_version()
self.cpuinfo.hf_abi = detect_hardfloat()
+ self.cpuinfo.neon = detect_neon()
#self.codemap.setup()
self.assembler.setup_once()
More information about the pypy-commit
mailing list