[pypy-svn] r34347 - in pypy/dist/pypy/jit/codegen/ppc: . test

mwh at codespeak.net mwh at codespeak.net
Tue Nov 7 20:36:45 CET 2006


Author: mwh
Date: Tue Nov  7 20:36:42 2006
New Revision: 34347

Modified:
   pypy/dist/pypy/jit/codegen/ppc/regalloc.py
   pypy/dist/pypy/jit/codegen/ppc/rgenop.py
   pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py
Log:
reorganize the way we list the registers we consider for allocation.


Modified: pypy/dist/pypy/jit/codegen/ppc/regalloc.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/regalloc.py	(original)
+++ pypy/dist/pypy/jit/codegen/ppc/regalloc.py	Tue Nov  7 20:36:42 2006
@@ -5,16 +5,15 @@
      rSCRATCH
 
 class RegisterAllocation:
-    def __init__(self, minreg, initial_mapping, initial_spill_offset):
+    def __init__(self, freeregs, initial_mapping, initial_spill_offset):
         #print
         #print "RegisterAllocation __init__", initial_mapping
 
         self.insns = []   # Output list of instructions
         # Registers with dead values
-        self.freeregs = {GP_REGISTER:gprs[minreg:],
-                         FP_REGISTER:fprs[:],
-                         CR_FIELD:crfs[:],
-                         CT_REGISTER:[ctr]}
+        self.freeregs = {}
+        for regcls in freeregs:
+            self.freeregs[regcls] = freeregs[regcls][:]
         self.var2loc = {} # Maps a Var to an AllocationSlot
         self.loc2var = {} # Maps an AllocationSlot to a Var
         self.lru = []     # Least-recently-used list of vars; first is oldest.

Modified: pypy/dist/pypy/jit/codegen/ppc/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/ppc/rgenop.py	Tue Nov  7 20:36:42 2006
@@ -222,7 +222,7 @@
     def allocate_and_emit(self):
         assert self.initial_var2loc is not None
         allocator = RegisterAllocation(
-            self.rgenop.MINUSERREG, self.initial_var2loc, self.initial_spill_offset)
+            self.rgenop.freeregs, self.initial_var2loc, self.initial_spill_offset)
         self.insns = allocator.allocate_for_insns(self.insns)
         if self.insns:
             self.patch_stack_adjustment(self._stack_size(0, allocator.spill_offset))
@@ -318,7 +318,7 @@
                 else:
                     usedregs[loc] = None # XXX use this
 
-        unusedregs = [loc for loc in gprs[self.rgenop.MINUSERREG:] if loc not in usedregs]
+        unusedregs = [loc for loc in self.rgenop.freeregs[insn.GP_REGISTER] if loc not in usedregs]
         arg_locations = []
 
         for i in range(len(args_gv)):
@@ -457,9 +457,13 @@
 
 class RPPCGenOp(AbstractRGenOp):
 
-    # minimum register we will use for register allocation
+    # the set of registers we consider available for allocation
     # we can artifically restrict it for testing purposes
-    MINUSERREG = 3
+    freeregs = {
+        insn.GP_REGISTER:insn.gprs[3:],
+        insn.FP_REGISTER:insn.fprs,
+        insn.CR_FIELD:insn.crfs,
+        insn.CT_REGISTER:[insn.ctr]}
 
     def __init__(self):
         self.mcs = []   # machine code blocks where no-one is currently writing

Modified: pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py	Tue Nov  7 20:36:42 2006
@@ -3,9 +3,14 @@
 from pypy.rpython.lltypesystem import lltype
 from pypy.jit.codegen.test.rgenop_tests import AbstractRGenOpTests, FUNC2
 from ctypes import cast, c_int, c_void_p, CFUNCTYPE
+from pypy.jit.codegen.ppc import instruction as insn
 
 class FewRegisters(RPPCGenOp):
-    MINUSERREG = 29
+    freeregs = {
+        insn.GP_REGISTER:insn.gprs[29:],
+        insn.FP_REGISTER:insn.fprs,
+        insn.CR_FIELD:insn.crfs,
+        insn.CT_REGISTER:[insn.ctr]}
 
 class TestRPPCGenop(AbstractRGenOpTests):
     RGenOp = RPPCGenOp



More information about the Pypy-commit mailing list