Author: Richard Plangger <[email protected]>
Branch: s390x-backend
Changeset: r80231:c919b5688d2b
Date: 2015-10-15 11:54 +0200
http://bitbucket.org/pypy/pypy/changeset/c919b5688d2b/
Log: index base displace with a long displacement (20 bits instead of 12)
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
@@ -26,16 +26,15 @@
class Operand(object):
pass
-def build_rr(mnemonic, args):
- opcode = args[0]
+def build_rr(mnemonic, (opcode,)):
def encode_rr(self, reg1, reg2):
self.writechar(opcode)
operands = ((reg1 & 0x0f) << 4) | (reg2 & 0xf)
self.writechar(chr(operands))
return encode_rr
-def build_rre(mnemonic, args):
- opcode1,opcode2 = args[0]
+def build_rre(mnemonic, (opcode,)):
+ opcode1,opcode2 = opcode
def encode_rr(self, reg1, reg2):
self.writechar(opcode1)
self.writechar(opcode2)
@@ -45,8 +44,7 @@
self.writechar(chr(operands))
return encode_rr
-def build_rx(mnemonic, args):
- opcode = args[0]
+def build_rx(mnemonic, (opcode,)):
def encode_rx(self, reg_or_mask, idxbasedisp):
self.writechar(opcode)
index = idxbasedisp.index
@@ -60,6 +58,21 @@
return encode_rx
+def build_rxy(mnemonic, (opcode1,opcode2)):
+ def encode_rxy(self, reg_or_mask, idxbasedisp):
+ self.writechar(opcode1)
+ index = idxbasedisp.index
+ byte = (reg_or_mask & 0x0f) << 4 | index & 0xf
+ self.writechar(chr(byte))
+ displace = idxbasedisp.displace & 0x3ff
+ base = idxbasedisp.base & 0xf
+ byte = displace >> 8 & 0xf | base << 4
+ self.writechar(chr(byte))
+ self.writechar(chr(displace & 0xff))
+ self.writechar(chr(displace >> 12 & 0xff))
+ self.writechar(opcode2)
+
+ return encode_rxy
def build_instr_codes(clazz):
_mnemonic_codes = {
@@ -67,6 +80,8 @@
'AGR': (build_rre, ['\xB9\x08']),
'AGFR': (build_rre, ['\xB9\x18']),
'A': (build_rx, ['\x5A']),
+ 'AY': (build_rxy, ['\xE3','\x5A']),
+ 'AG': (build_rxy, ['\xE3','\x08']),
}
for mnemonic, (builder, args) in _mnemonic_codes.items():
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
@@ -91,6 +91,7 @@
accept_unnecessary_prefix = None
methname = '?'
INDEX_BASE_DISPLACE = build_idx_base_disp(8,8,12)
+ INDEX_BASE_DISPLACE_LONG = build_idx_base_disp(8,8,20)
def reg_tests(self):
return self.REGS
@@ -137,12 +138,18 @@
def assembler_operand_reg(self, regnum):
return self.REGNAMES[regnum]
- def get_all_assembler_operands(self):
+ def get_mapping_asm_to_str(self):
return {
'r': self.assembler_operand_reg,
'x': lambda x: str(x),
+ 'y': lambda x: str(x),
}
+ def operand_combinations(self, modes, arguments):
+ mapping = self.get_mapping_asm_to_str()
+ for mode, args in zip(modes, arguments):
+ yield mapping[mode](args)
+
def run_test(self, methname, instrname, argmodes, args_lists,
instr_suffix=None):
global labelcount
@@ -158,12 +165,8 @@
suffix = ""
if instr_suffix is not None:
suffix = instr_suffix # overwrite
-
- assembler_operand = self.get_all_assembler_operands()
- ops = []
- for mode, v in zip(argmodes, args):
- ops.append(assembler_operand[mode](v))
#
+ ops = self.operand_combinations(argmodes, args)
op = '\t%s%s %s' % (instrname.lower(), suffix,
', '.join(ops))
g.write('%s\n' % op)
@@ -197,11 +200,17 @@
raise Exception("Assembler did not produce output?")
return oplist, as_code
+ def modes(self, mode):
+ if mode == "rxy":
+ return "ry"
+ return mode
+
def make_all_tests(self, methname, modes, args=[]):
tests = {
'r': self.REGS,
'e': None,
'x': self.INDEX_BASE_DISPLACE,
+ 'y': self.INDEX_BASE_DISPLACE_LONG,
}
combinations = []
for m in modes:
@@ -222,6 +231,7 @@
instrname, argmodes = methname.split('_')
else:
instrname, argmodes = methname, ''
+ argmodes = self.modes(argmodes)
if self.should_skip_instruction(instrname, argmodes):
print "Skipping %s" % methname
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit