[pypy-svn] r73909 - in pypy/branch/blackhole-improvement/pypy/jit/codewriter: . test

arigo at codespeak.net arigo at codespeak.net
Tue Apr 20 15:04:41 CEST 2010


Author: arigo
Date: Tue Apr 20 15:04:40 2010
New Revision: 73909

Modified:
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/flatten.py
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/format.py
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_assembler.py
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_format.py
Log:
Store the kind on each Register.


Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/flatten.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/flatten.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/flatten.py	Tue Apr 20 15:04:40 2010
@@ -24,7 +24,8 @@
         return isinstance(other, TLabel) and other.name == self.name
 
 class Register(object):
-    def __init__(self, index):
+    def __init__(self, kind, index):
+        self.kind = kind
         self.index = index
 
 # ____________________________________________________________
@@ -170,7 +171,7 @@
         kind = getkind(v.concretetype)
         col = self.regallocs[kind].getcolor(v)    # if kind=='void', fix caller
         try:
-            r = self.registers[col]
+            r = self.registers[kind, col]
         except KeyError:
-            r = self.registers[col] = Register(col)
+            r = self.registers[kind, col] = Register(kind, col)
         return r

Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/format.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/format.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/format.py	Tue Apr 20 15:04:40 2010
@@ -10,7 +10,7 @@
     #
     def repr(x):
         if isinstance(x, Register):
-            return '%i' + str(x.index)
+            return '%%%s%d' % (x.kind[0], x.index)    # e.g. %i1 or %r2 or %f3
         elif isinstance(x, Constant):
             return '$' + str(x.value)
         elif isinstance(x, TLabel):

Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_assembler.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_assembler.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_assembler.py	Tue Apr 20 15:04:40 2010
@@ -6,7 +6,7 @@
 
 def test_assemble_simple():
     ssarepr = SSARepr("test")
-    i0, i1, i2 = Register(0), Register(1), Register(2)
+    i0, i1, i2 = Register('int', 0), Register('int', 1), Register('int', 2)
     ssarepr.insns = [
         ('int_add', i0, i1, i2),
         ('int_return', i2),
@@ -21,7 +21,7 @@
 def test_assemble_consts():
     ssarepr = SSARepr("test")
     ssarepr.insns = [
-        ('int_return', Register(13)),
+        ('int_return', Register('int', 13)),
         ('int_return', Constant(18)),
         ('int_return', Constant(-4)),
         ('int_return', Constant(128)),
@@ -40,7 +40,7 @@
 
 def test_assemble_loop():
     ssarepr = SSARepr("test")
-    i0, i1 = Register(0x16), Register(0x17)
+    i0, i1 = Register('int', 0x16), Register('int', 0x17)
     ssarepr.insns = [
         (Label('L1'),),
         ('goto_if_not_int_gt', TLabel('L2'), i0, Constant(4)),

Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_format.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_format.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_format.py	Tue Apr 20 15:04:40 2010
@@ -6,7 +6,7 @@
 
 def test_format_assembler_simple():
     ssarepr = SSARepr("test")
-    i0, i1, i2 = Register(0), Register(1), Register(2)
+    i0, i1, i2 = Register('int', 0), Register('int', 1), Register('int', 2)
     ssarepr.insns = [
         ('foobar', [i0, i1]),
         ('int_add', i0, i1, i2),
@@ -20,9 +20,21 @@
     """
     assert asm == str(py.code.Source(expected)).strip() + '\n'
 
+def test_format_assembler_float():
+    ssarepr = SSARepr("test")
+    i1, r2, f3 = Register('int', 1), Register('ref', 2), Register('float', 3)
+    ssarepr.insns = [
+        ('foobar', i1, r2, f3),
+        ]
+    asm = format_assembler(ssarepr)
+    expected = """
+        foobar %i1, %r2, %f3
+    """
+    assert asm == str(py.code.Source(expected)).strip() + '\n'
+
 def test_format_assembler_loop():
     ssarepr = SSARepr("test")
-    i0, i1 = Register(0), Register(1)
+    i0, i1 = Register('int', 0), Register('int', 1)
     ssarepr.insns = [
         ('foobar', [i0, i1]),
         (Label('L1'),),



More information about the Pypy-commit mailing list