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

mwh at codespeak.net mwh at codespeak.net
Fri Feb 9 17:38:23 CET 2007


Author: mwh
Date: Fri Feb  9 17:38:09 2007
New Revision: 38270

Modified:
   pypy/dist/pypy/jit/codegen/ppc/instruction.py
   pypy/dist/pypy/jit/codegen/ppc/rgenop.py
   pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py
Log:
pass the read_frame_var tests too.


Modified: pypy/dist/pypy/jit/codegen/ppc/instruction.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/instruction.py	(original)
+++ pypy/dist/pypy/jit/codegen/ppc/instruction.py	Fri Feb  9 17:38:09 2007
@@ -536,6 +536,20 @@
     def emit(self, asm):
         asm.stw(self.arg_reg.number, rFP, self.target_slot.offset)
 
+class CopyOffStack(Insn):
+    def __init__(self, v, place):
+        Insn.__init__(self)
+        self.reg_args = []
+        self.reg_arg_regclasses = []
+        self.result = v
+        self.result_regclass = GP_REGISTER
+        self.place = place
+    def allocate(self, allocator):
+        self.result_reg = allocator.loc_of(self.result)
+        allocator.free_stack_slots.append(stack_slot(self.place.offset))
+    def emit(self, asm):
+        asm.lwz(self.result_reg.number, rFP, self.place.offset)
+
 class SpillCalleeSaves(Insn):
     def __init__(self):
         Insn.__init__(self)

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	Fri Feb  9 17:38:09 2007
@@ -243,7 +243,6 @@
         self.initial_var2loc = None
         self.max_param_space = -1
         self.final_jump_addr = 0
-        self.forced_into_stack = None
 
         self.start = 0
         self.closed = True
@@ -383,19 +382,26 @@
         return gv_result
 
     def get_frame_info(self, vars_gv):
-        if self.forced_into_stack is None:
-            self.forced_into_stack = []
         result = []
         for v in vars_gv:
             if isinstance(v, Var):
                 place = StackInfo()
                 self.insns.append(insn.CopyIntoStack(place, v))
-                self.forced_into_stack.append((v, place))
                 result.append(place)
             else:
                 result.append(None)
         return result
 
+    def alloc_frame_place(self, kind, gv_initial_value):
+        place = StackInfo()
+        self.insns.append(insn.CopyIntoStack(place, gv_initial_value))
+        return place
+
+    def genop_absorb_place(self, kind, place):
+        var = Var()
+        self.insns.append(insn.CopyOffStack(var, place))
+        return var
+
     def enter_next_block(self, kinds, args_gv):
         if DEBUG_PRINT:
             print 'enter_next_block1', args_gv
@@ -1072,6 +1078,15 @@
     else:
         return lltype.cast_primitive(T, value)
 
+ at specialize.arg(0)
+def cast_whatever_to_int(T, value):
+    if isinstance(T, lltype.Ptr):
+        return lltype.cast_ptr_to_int(value)
+    elif T is llmemory.Address:
+        return llmemory.cast_adr_to_int(value)
+    else:
+        return lltype.cast_primitive(lltype.Signed, value)
+
 class RPPCGenOp(AbstractRGenOp):
 
     # the set of registers we consider available for allocation
@@ -1201,19 +1216,19 @@
             assert isinstance(place, GenConst)
             return place.revealconst(T)
 
-    #@staticmethod
-    #@specialize.arg(0)
-    #def write_frame_place(T, base, place, value):
-    #    """Write into a place in the stack frame of a caller.  The
-    #    'base' is the frame stack pointer captured by the operation
-    #    generated by genop_get_frame_base()."""
-
-    #@staticmethod
-    #@specialize.arg(0)
-    #def read_frame_place(T, base, place):
-    #    """Read from a place in the stack frame of a caller.  The
-    #    'base' is the frame stack pointer captured by the operation
-    #    generated by genop_get_frame_base()."""
+
+    @staticmethod
+    @specialize.arg(0)
+    def write_frame_place(T, base, place, value):
+        assert place.offset != 0
+        value = cast_whatever_to_int(T, value)
+        poke_word_into(base + place.offset, value)
+
+    @staticmethod
+    @specialize.arg(0)
+    def read_frame_place(T, base, place):
+        value = peek_word_at(base + place.offset)
+        return cast_int_to_whatever(T, value)
 
     def check_no_open_mc(self):
         pass
@@ -1329,3 +1344,14 @@
         from ctypes import cast, c_void_p, c_int, POINTER
         p = cast(c_void_p(addr), POINTER(c_int))
         return p[0]
+
+def poke_word_into(addr, value):
+    # now the Very Obscure Bit: when translated, 'addr' is an
+    # address.  When not, it's an integer.  It just happens to
+    # make the test pass, but that's probably going to change.
+    if we_are_translated():
+        addr.signed[0] = value
+    else:
+        from ctypes import cast, c_void_p, c_int, POINTER
+        p = cast(c_void_p(addr), POINTER(c_int))
+        p[0] = value

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	Fri Feb  9 17:38:09 2007
@@ -21,13 +21,6 @@
 class TestRPPCGenop(AbstractRGenOpTests):
     RGenOp = RPPCGenOp
 
-#    def test_read_frame_var_direct(self):   py.test.skip("in-progress")
-#    def test_read_frame_var_compile(self):  py.test.skip("in-progress")
-    def test_write_frame_place_direct(self):  py.test.skip("in-progress")
-    def test_write_frame_place_compile(self): py.test.skip("in-progress")
-    def test_read_frame_place_direct(self):  py.test.skip("in-progress")
-    def test_read_frame_place_compile(self): py.test.skip("in-progress")
-
 
 class TestRPPCGenopNoRegs(TestRPPCGenop):
     RGenOp = FewRegisters



More information about the Pypy-commit mailing list