[pypy-svn] r51379 - in pypy/dist/pypy/jit/codegen/cli: . test
antocuni at codespeak.net
antocuni at codespeak.net
Mon Feb 11 11:57:25 CET 2008
Author: antocuni
Date: Mon Feb 11 11:57:24 2008
New Revision: 51379
Modified:
pypy/dist/pypy/jit/codegen/cli/operation.py
pypy/dist/pypy/jit/codegen/cli/rgenop.py
pypy/dist/pypy/jit/codegen/cli/test/test_rgenop.py
Log:
fix restype() for cast operations; test_multiple_cmps pass
Modified: pypy/dist/pypy/jit/codegen/cli/operation.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/cli/operation.py (original)
+++ pypy/dist/pypy/jit/codegen/cli/operation.py Mon Feb 11 11:57:24 2008
@@ -44,6 +44,8 @@
self.il.Emit(self.getOpCode())
self.storeResult()
+ def getOpCode(self):
+ raise NotImplementedError
class BinaryOp(Operation):
def __init__(self, il, gv_x, gv_y):
@@ -157,11 +159,15 @@
return True
return False
-def fillops(ops, baseclass):
- # monkey-patch boolean operations
- def restype(self):
- return typeof(System.Boolean)
+def restype_bool(self): return typeof(System.Boolean)
+def restype_int(self): return typeof(System.Int32)
+def restype_uint(self): return typeof(System.Int32)
+def restype_float(self): return typeof(System.Double)
+def restype_char(self): return typeof(System.Char)
+def restype_unichar(self): return typeof(System.Char)
+def restype_longlong(self): return typeof(System.Int64)
+def fillops(ops, baseclass):
out = {}
for opname, value in ops.iteritems():
if isinstance(value, str):
@@ -173,12 +179,19 @@
""" % locals())
code = source.compile()
exec code in globals(), out
- if is_comparison(opname):
- out[opname].restype = restype
elif value is cli_opcodes.DoNothing:
out[opname] = SameAs
else:
renderCustomOp(opname, baseclass, value, out)
+
+ # fix the restype for comparison ops and casts
+ if is_comparison(opname):
+ out[opname].restype = restype_bool
+ elif opname != 'cast_primitive' and opname.startswith('cast_'):
+ _, _, _, to = opname.split('_')
+ funcname = 'restype_%s' % to
+ out[opname].restype = globals()[funcname]
+
return out
def renderCustomOp(opname, baseclass, steps, out):
Modified: pypy/dist/pypy/jit/codegen/cli/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/cli/rgenop.py (original)
+++ pypy/dist/pypy/jit/codegen/cli/rgenop.py Mon Feb 11 11:57:24 2008
@@ -11,6 +11,7 @@
Constants = CLR.pypy.runtime.Constants
OpCodes = System.Reflection.Emit.OpCodes
+DUMP_IL = False
DEBUG = False
def token2clitype(tok):
@@ -208,7 +209,7 @@
self.rgenop = rgenop
self.meth = Utils.CreateDynamicMethod(name, res, args)
self.il = self.meth.GetILGenerator()
- if DEBUG:
+ if DUMP_IL:
self.il = DumpGenerator(self.il)
self.inputargs_gv = []
for i in range(len(args)):
@@ -226,14 +227,36 @@
opcls = ops.getopclass1(opname)
op = opcls(self.il, gv_arg)
self.emit(op)
- return op.gv_res()
+ gv_res = op.gv_res()
+ if DEBUG:
+ self.il.EmitWriteLine(opname)
+ self.writeline_gv(gv_arg)
+ self.writeline_gv(gv_res)
+ self.il.EmitWriteLine('')
+ return gv_res
+
@specialize.arg(1)
def genop2(self, opname, gv_arg1, gv_arg2):
opcls = ops.getopclass2(opname)
op = opcls(self.il, gv_arg1, gv_arg2)
self.emit(op)
- return op.gv_res()
+ gv_res = op.gv_res()
+ if DEBUG:
+ self.il.EmitWriteLine(opname)
+ self.writeline_gv(gv_arg1)
+ self.writeline_gv(gv_arg2)
+ self.writeline_gv(gv_res)
+ self.il.EmitWriteLine('')
+ return gv_res
+
+ def writeline_gv(self, gv):
+ if isinstance(gv, GenLocalVar):
+ self.il.EmitWriteLine(gv.v)
+ elif isinstance(gv, IntConst):
+ self.il.EmitWriteLine('%s' % gv.value)
+ else:
+ assert False
def genop_call(self, sigtoken, gv_fnptr, args_gv):
op = ops.Call(self.il, sigtoken, gv_fnptr, args_gv)
Modified: pypy/dist/pypy/jit/codegen/cli/test/test_rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/cli/test/test_rgenop.py (original)
+++ pypy/dist/pypy/jit/codegen/cli/test/test_rgenop.py Mon Feb 11 11:57:24 2008
@@ -20,6 +20,7 @@
'test_calling_pause',
'test_longwinded_and',
'test_condition_result_cross_link_direct',
+ 'test_multiple_cmps',
]
for p in prefixes:
More information about the Pypy-commit
mailing list