[pypy-commit] pypy s390x-5.3-catchup: merged default
plan_rich
pypy.commits at gmail.com
Tue Jun 7 09:06:07 EDT 2016
Author: Richard Plangger <planrichi at gmail.com>
Branch: s390x-5.3-catchup
Changeset: r84993:772d2e282f99
Date: 2016-06-07 14:27 +0200
http://bitbucket.org/pypy/pypy/changeset/772d2e282f99/
Log: merged default
diff --git a/pypy/doc/whatsnew-pypy2-5.3.0.rst b/pypy/doc/whatsnew-pypy2-5.3.0.rst
--- a/pypy/doc/whatsnew-pypy2-5.3.0.rst
+++ b/pypy/doc/whatsnew-pypy2-5.3.0.rst
@@ -143,3 +143,11 @@
Finish the work already partially merged in cpyext-for-merge. Adds support
for ByteArrayObject using the nonmovable-list, which also enables
buffer(bytearray(<some-list>))
+
+.. branch: z196-support
+
+Fixes a critical issue in the register allocator and extends support on s390x.
+PyPy runs and translates on the s390x revisions z10 (released February 2008, experimental)
+and z196 (released August 2010) in addition to zEC12 and z13.
+To target e.g. z196 on a zEC12 machine supply CFLAGS="-march=z196" to your shell environment.
+
diff --git a/pypy/module/select/test/test_epoll.py b/pypy/module/select/test/test_epoll.py
--- a/pypy/module/select/test/test_epoll.py
+++ b/pypy/module/select/test/test_epoll.py
@@ -20,6 +20,10 @@
self.w_sockets = self.space.wrap([])
if platform.machine().startswith('arm'):
self.w_timeout = self.space.wrap(0.06)
+ if platform.machine().startswith('s390x'):
+ # s390x is not slow, but it seems there is one case when epoll
+ # modify method is called that takes longer on s390x
+ self.w_timeout = self.space.wrap(0.06)
else:
self.w_timeout = self.space.wrap(0.02)
diff --git a/rpython/doc/arch/index.rst b/rpython/doc/arch/index.rst
new file mode 100644
--- /dev/null
+++ b/rpython/doc/arch/index.rst
@@ -0,0 +1,11 @@
+.. _arch_index:
+
+Architecture specific notes
+===========================
+
+Here you can find some architecture specific notes.
+
+.. toctree::
+ :maxdepth: 1
+
+ s390x
diff --git a/rpython/doc/arch/s390x.rst b/rpython/doc/arch/s390x.rst
new file mode 100644
--- /dev/null
+++ b/rpython/doc/arch/s390x.rst
@@ -0,0 +1,34 @@
+.. _s390x:
+
+IBM Mainframe S390X
+===================
+
+Our JIT implements the 64 bit version of the IBM Mainframe called s390x.
+Note that this architecture is big endian.
+
+Currently supported ISAs:
+
+* z13 (released January 2015)
+* zEC12 (released September 2012)
+* z196 (released August 2010)
+* z10 (released February 2008)
+
+To check if all the necessary CPU facilities are installed
+on the subject machine, please run the test using a copy of the pypy
+source code::
+
+ $ ./pytest.py rpython/jit/backend/zarch/test/test_assembler -v -k 'test_facility'
+
+In addition you can run the auto encoding test to check if your Linux GCC tool chain
+is able to compile all instructions used in the JIT backend::
+
+ $ ./pytest.py rpython/jit/backend/zarch/test/test_auto_encoding.py -v
+
+Translating
+-----------
+
+Specifically check for these two dependencies. On old versions of some
+Linux distributions ship older versions.
+
+* libffi (version should do > 3.0.+).
+* CPython 2.7.+.
diff --git a/rpython/doc/index.rst b/rpython/doc/index.rst
--- a/rpython/doc/index.rst
+++ b/rpython/doc/index.rst
@@ -37,7 +37,6 @@
arm
logging
- s390x
Writing your own interpreter in RPython
@@ -61,6 +60,7 @@
getting-started
dir-reference
jit/index
+ arch/index
translation
rtyper
garbage_collection
diff --git a/rpython/doc/s390x.rst b/rpython/doc/s390x.rst
deleted file mode 100644
--- a/rpython/doc/s390x.rst
+++ /dev/null
@@ -1,20 +0,0 @@
-.. _s390x:
-
-S390X JIT Backend
-=================
-
-Our JIT implements the 64 bit version of the IBM Mainframe called s390x.
-Note that this architecture is big endian.
-
-The following facilities need to be installed to operate
-correctly (all of the machines used for development these where installed):
-
-* General-Instructions-Extension
-* Long-Displacement
-* Binary Floating Point (IEEE)
-
-Translating
------------
-
-Ensure that libffi is installed (version should do > 3.0.+).
-CPython should be version 2.7.+.
diff --git a/rpython/jit/backend/zarch/instructions.py b/rpython/jit/backend/zarch/instructions.py
--- a/rpython/jit/backend/zarch/instructions.py
+++ b/rpython/jit/backend/zarch/instructions.py
@@ -45,7 +45,6 @@
# rotating
'RISBG': ('rie_f', ['\xEC','\x55']),
- 'RISBGN': ('rie_f', ['\xEC','\x59']),
# invert & negative & absolute
'LPGR': ('rre', ['\xB9','\x00']),
diff --git a/rpython/jit/backend/zarch/test/test_assembler.py b/rpython/jit/backend/zarch/test/test_assembler.py
--- a/rpython/jit/backend/zarch/test/test_assembler.py
+++ b/rpython/jit/backend/zarch/test/test_assembler.py
@@ -155,7 +155,15 @@
s64 = bin(fac_data[1])[2:]
print(f64)
print(s64)
+ for i,c in enumerate(f64):
+ print('index: %d is set? %s' % (i,c))
+
+ assert f64[1] == '1' # The z/Architecture architectural mode is installed.
+ assert f64[2] == '1' # The z/Architecture architectural mode is active.
assert f64[18] == '1' # long displacement facility
+ assert f64[21] == '1' # extended immediate facility
+ assert f64[34] == '1' # general instruction facility
+ assert f64[41] == '1' # floating-point-support-enhancement
def test_load_byte_zero_extend(self):
adr = self.a.datablockwrapper.malloc_aligned(16, 16)
@@ -189,7 +197,7 @@
@py.test.mark.parametrize('p', [2**32,2**32+1,2**63-1,2**63-2,0,1,2,3,4,5,6,7,8,10001])
def test_align_withroll(self, p):
self.a.mc.load_imm(r.r2, p & 0xffffFFFFffffFFFF)
- self.a.mc.RISBGN(r.r2, r.r2, loc.imm(0), loc.imm(0x80 | 60), loc.imm(0))
+ self.a.mc.RISBG(r.r2, r.r2, loc.imm(0), loc.imm(0x80 | 60), loc.imm(0))
self.a.mc.BCR(con.ANY, r.r14)
assert run_asm(self.a) == rffi.cast(rffi.ULONG,p) & ~(7)
@@ -214,7 +222,7 @@
n = 13
l = loc
self.a.mc.load_imm(r.r2, 7<<n)
- self.a.mc.RISBGN(r.r2, r.r2, l.imm(61), l.imm(0x80 | 63), l.imm(64-n))
+ self.a.mc.RISBG(r.r2, r.r2, l.imm(61), l.imm(0x80 | 63), l.imm(64-n))
self.a.mc.BCR(con.ANY, r.r14)
assert run_asm(self.a) == 7
@@ -222,7 +230,7 @@
n = 16
l = loc
self.a.mc.load_imm(r.r2, 0xffFFffFF)
- self.a.mc.RISBGN(r.r2, r.r2, l.imm(60), l.imm(0x80 | 63), l.imm(64-n))
+ self.a.mc.RISBG(r.r2, r.r2, l.imm(60), l.imm(0x80 | 63), l.imm(64-n))
self.a.mc.BCR(con.ANY, r.r14)
assert run_asm(self.a) == 15
diff --git a/rpython/jit/backend/zarch/test/test_auto_encoding.py b/rpython/jit/backend/zarch/test/test_auto_encoding.py
--- a/rpython/jit/backend/zarch/test/test_auto_encoding.py
+++ b/rpython/jit/backend/zarch/test/test_auto_encoding.py
@@ -204,7 +204,7 @@
g.write('%s\n' % op)
oplist.append(op)
g.write('\t.string "%s"\n' % END_TAG)
- proc = subprocess.Popen(['as', '-m64', '-mzarch', '-march=zEC12',
+ proc = subprocess.Popen(['as', '-m64', '-mzarch', '-march=z196',
inputname, '-o', filename],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
diff --git a/rpython/translator/platform/arch/__init__.py b/rpython/translator/platform/arch/__init__.py
new file mode 100644
diff --git a/rpython/translator/platform/arch/s390x.py b/rpython/translator/platform/arch/s390x.py
new file mode 100644
--- /dev/null
+++ b/rpython/translator/platform/arch/s390x.py
@@ -0,0 +1,86 @@
+import re
+
+def extract_s390x_cpu_ids(lines):
+ """ NOT_RPYTHON """
+ ids = []
+
+ re_number = re.compile("processor (\d+):")
+ re_version = re.compile("version = ([0-9A-Fa-f]+)")
+ re_id = re.compile("identification = ([0-9A-Fa-f]+)")
+ re_machine = re.compile("machine = ([0-9A-Fa-f]+)")
+ for line in lines:
+ number = -1
+ version = None
+ ident = None
+ machine = 0
+
+ match = re_number.match(line)
+ if not match:
+ continue
+ number = int(match.group(1))
+
+ match = re_version.search(line)
+ if match:
+ version = match.group(1)
+
+ match = re_version.search(line)
+ if match:
+ version = match.group(1)
+
+ match = re_id.search(line)
+ if match:
+ ident = match.group(1)
+
+ match = re_machine.search(line)
+ if match:
+ machine = int(match.group(1), 16)
+
+ ids.append((number, version, ident, machine))
+
+ return ids
+
+
+def s390x_cpu_revision():
+ """ NOT_RPYTHON """
+ # linux kernel does the same classification
+ # http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20131028/193311.html
+
+ with open("/proc/cpuinfo", "rb") as fd:
+ lines = fd.read().splitlines()
+ cpu_ids = extract_s390x_cpu_ids(lines)
+ machine = -1
+ for number, version, id, m in cpu_ids:
+ if machine != -1:
+ assert machine == m
+ machine = m
+
+ if machine == 0x2097 or machine == 0x2098:
+ return "z10"
+ if machine == 0x2817 or machine == 0x2818:
+ return "z196"
+ if machine == 0x2827 or machine == 0x2828:
+ return "zEC12"
+ if machine == 0x2964:
+ return "z13"
+
+ # well all others are unsupported!
+ return "unknown"
+
+def update_cflags(cflags):
+ """ NOT_RPYTHON """
+ # force the right target arch for s390x
+ for cflag in cflags:
+ if cflag.startswith('-march='):
+ break
+ else:
+ # the default cpu architecture that is supported
+ # older versions are not supported
+ revision = s390x_cpu_revision()
+ if revision == 'z13':
+ # gcc does not recognize z13 as a compiler flag!
+ revision = 'zEC12'
+
+ assert revision != 'unknown'
+ cflags += ('-march='+revision,)
+ cflags += ('-m64','-mzarch')
+ return cflags
diff --git a/rpython/translator/platform/arch/test/test_s390x.py b/rpython/translator/platform/arch/test/test_s390x.py
new file mode 100644
--- /dev/null
+++ b/rpython/translator/platform/arch/test/test_s390x.py
@@ -0,0 +1,22 @@
+import py
+import platform
+from rpython.translator.platform.arch.s390x import (s390x_cpu_revision,
+ extract_s390x_cpu_ids)
+
+if platform.machine() != 's390x':
+ py.test.skip("s390x tests only")
+
+def test_cpuid_s390x():
+ revision = s390x_cpu_revision()
+ assert revision != 'unknown', 'the model you are running on might be too old'
+
+def test_read_processor_info():
+ ids = extract_s390x_cpu_ids("""
+processor 0: machine = 12345
+processor 1: version = FF, identification = AF
+ """.splitlines())
+ assert ids == [(0, None, None, 12345),
+ (1, 'FF', 'AF', 0),
+ ]
+
+
diff --git a/rpython/translator/platform/linux.py b/rpython/translator/platform/linux.py
--- a/rpython/translator/platform/linux.py
+++ b/rpython/translator/platform/linux.py
@@ -22,8 +22,8 @@
so_prefixes = ('lib', '')
if platform.machine() == 's390x':
- # force the right target arch for s390x
- cflags = ('-march=zEC12','-m64','-mzarch') + cflags
+ from rpython.translator.platform.arch import s390x
+ cflags = s390x.update_cflags(cflags)
def _args_for_shared(self, args):
return ['-shared'] + args
More information about the pypy-commit
mailing list