[pypy-commit] pypy s390x-backend: variations of AND, OR, XOR (reg-reg, reg-mem)
plan_rich
noreply at buildbot.pypy.org
Tue Oct 20 06:17:43 EDT 2015
Author: Richard Plangger <planrichi at gmail.com>
Branch: s390x-backend
Changeset: r80353:43eb605709b5
Date: 2015-10-20 12:06 +0200
http://bitbucket.org/pypy/pypy/changeset/43eb605709b5/
Log: variations of AND, OR, XOR (reg-reg, reg-mem)
diff --git a/rpython/jit/backend/zarch/codebuilder.py b/rpython/jit/backend/zarch/codebuilder.py
--- a/rpython/jit/backend/zarch/codebuilder.py
+++ b/rpython/jit/backend/zarch/codebuilder.py
@@ -8,7 +8,6 @@
from rpython.rtyper.lltypesystem import lltype, rffi, llmemory
from rpython.tool.udir import udir
from rpython.jit.backend.detect_cpu import autodetect
-from rpython.rtyper.lltypesystem.rbuilder import always_inline
clear_cache = rffi.llexternal(
"__clear_cache",
diff --git a/rpython/jit/backend/zarch/instruction_builder.py b/rpython/jit/backend/zarch/instruction_builder.py
--- a/rpython/jit/backend/zarch/instruction_builder.py
+++ b/rpython/jit/backend/zarch/instruction_builder.py
@@ -1,6 +1,6 @@
-from rpython.jit.backend.zarch.instructions import (all_mnemonic_codes,
- arith_mnemic_codes, branch_mnemoic_codes)
+from rpython.jit.backend.zarch.instructions import (all_mnemonic_codes,)
from rpython.rtyper.lltypesystem.rbuilder import always_inline
+from rpython.rlib.unroll import unrolling_iterable
class builder(object):
@@ -14,9 +14,9 @@
r/m - register or mask
iX - immediate X bits (signed)
uX - immediate X bits (unsigend)
- bd - base displacement (12 bit)
+ bd - base displacement (unsigned 12 bit)
bdl - base displacement long (20 bit)
- bid - index base displacement
+ bid - index base displacement (unsigned 12 bit)
bidl - index base displacement (20 bit)
l4bd - length base displacement (4 bit)
l8bd - length base displacement (8 bit)
@@ -118,6 +118,12 @@
self.writechar(chr(imm16 & 0xff))
return encode_ri
+def build_ri_u(mnemonic, (opcode,halfopcode)):
+ # unsigned version of ri
+ func = build_ri(mnemonic, (opcode,halfopcode))
+ func._arguments_[1] = 'u16'
+ return func
+
def build_ril(mnemonic, (opcode,halfopcode)):
br = is_branch_relative(mnemonic)
@builder.arguments('r/m,i32')
@@ -270,7 +276,12 @@
return name.startswith('BR')
def build_instr_codes(clazz):
- for mnemonic, (instrtype, args) in all_mnemonic_codes.items():
+ for mnemonic, params in all_mnemonic_codes.items():
+ options = {}
+ if len(params) == 2:
+ (instrtype, args) = params
+ else:
+ (instrtype, args, options) = params
builder = globals()['build_' + instrtype]
func = builder(mnemonic, args)
name = mnemonic + "_" + instrtype
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
@@ -1,5 +1,5 @@
-branch_mnemoic_codes = {
+branch_mnemonic_codes = {
'BRASL': ('ril', ['\xC0','\x05']),
'BCR': ('rr', ['\x07']),
'BC': ('rx', ['\x47']),
@@ -7,7 +7,7 @@
'BRCL': ('ril', ['\xC0','\x04']),
}
-arith_mnemic_codes = {
+arith_mnemonic_codes = {
'AR': ('rr', ['\x1A']),
'AGR': ('rre', ['\xB9','\x08']),
'AGFR': ('rre', ['\xB9','\x18']),
@@ -16,6 +16,47 @@
'SGR': ('rre', ['\xB9','\x09']),
}
+logic_mnemonic_codes = {
+ # AND operations
+ 'NGR': ('rre', ['\xB9','\x80']),
+ 'NG': ('rxy', ['\xE3','\x80']),
+ # and one byte and store it back at the op2 position
+ 'NI': ('si', ['\x94']),
+ 'NIY': ('siy', ['\xEB','\x54']),
+
+ # AND immediate
+ 'NIHH': ('ri_u', ['\xA5', '\x04']),
+ 'NIHL': ('ri_u', ['\xA5', '\x05']),
+ 'NILH': ('ri_u', ['\xA5', '\x06']),
+ 'NILL': ('ri_u', ['\xA5', '\x07']),
+
+ # OR operations
+ 'OGR': ('rre', ['\xB9','\x81']),
+ 'OG': ('rxy', ['\xE3','\x81']),
+ # or one byte and store it back at the op2 position
+ 'OI': ('si', ['\x96']),
+ 'OIY': ('siy', ['\xEB','\x56']),
+
+ # OR immediate
+ 'OIHH': ('ri_u', ['\xA5', '\x08']),
+ 'OIHL': ('ri_u', ['\xA5', '\x09']),
+ 'OILH': ('ri_u', ['\xA5', '\x0A']),
+ 'OILL': ('ri_u', ['\xA5', '\x0B']),
+
+ # XOR operations
+ 'XGR': ('rre', ['\xB9','\x82']),
+ 'XG': ('rxy', ['\xE3','\x82']),
+ # or one byte and store it back at the op2 position
+ 'XI': ('si', ['\x97']),
+ 'XIY': ('siy', ['\xEB','\x57']),
+
+ # OR immediate
+ 'OIHH': ('ri_u', ['\xA5', '\x08']),
+ 'OIHL': ('ri_u', ['\xA5', '\x09']),
+ 'OILH': ('ri_u', ['\xA5', '\x0A']),
+ 'OILL': ('ri_u', ['\xA5', '\x0B']),
+}
+
all_mnemonic_codes = {
'AY': ('rxy', ['\xE3','\x5A']),
'AG': ('rxy', ['\xE3','\x08']),
@@ -44,6 +85,12 @@
'PKA': ('ssf', ['\xE9']),
'STMG': ('rsy', ['\xEB','\x24']),
}
-all_mnemonic_codes.update(arith_mnemic_codes)
-all_mnemonic_codes.update(branch_mnemoic_codes)
+all_mnemonic_codes.update(arith_mnemonic_codes)
+all_mnemonic_codes.update(logic_mnemonic_codes)
+all_mnemonic_codes.update(branch_mnemonic_codes)
+
+if __name__ == "__main__":
+ print("%d instructions:" % len(all_mnemonic_codes))
+ for name, (typeinstr, _) in all_mnemonic_codes.items():
+ print(" %s\t(type: %s)" % (name, typeinstr))
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
@@ -239,7 +239,7 @@
def complete_test(self, methname):
if '_' in methname:
- instrname, argmodes = methname.split('_')
+ instrname, argmodes = methname.split('_')[:2]
else:
instrname, argmodes = methname, ''
argmodes = self.modes(argmodes)
More information about the pypy-commit
mailing list