[pypy-commit] pypy s390x-backend: added debug increment as operation (regalloc + assembly)

plan_rich noreply at buildbot.pypy.org
Thu Nov 19 10:27:48 EST 2015


Author: Richard Plangger <planrichi at gmail.com>
Branch: s390x-backend
Changeset: r80778:bc577360b3d3
Date: 2015-11-19 16:28 +0100
http://bitbucket.org/pypy/pypy/changeset/bc577360b3d3/

Log:	added debug increment as operation (regalloc + assembly)

diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -4952,6 +4952,7 @@
     def test_increment_debug_counter(self):
         foo = lltype.malloc(rffi.CArray(lltype.Signed), 1, flavor='raw')
         foo[0] = 1789200
+        print "addr" , hex(rffi.cast(lltype.Signed, foo))
         self.execute_operation(rop.INCREMENT_DEBUG_COUNTER,
                                [ConstInt(rffi.cast(lltype.Signed, foo))],
                                'void')
diff --git a/rpython/jit/backend/zarch/assembler.py b/rpython/jit/backend/zarch/assembler.py
--- a/rpython/jit/backend/zarch/assembler.py
+++ b/rpython/jit/backend/zarch/assembler.py
@@ -583,9 +583,6 @@
     # ________________________________________
     # ASSEMBLER EMISSION
 
-    def emit_increment_debug_counter(self, op, arglocs, regalloc):
-        pass # TODO
-
     def emit_label(self, op, arglocs, regalloc):
         offset = self.pool.pool_start - self.mc.get_relative_pos()
         # load the pool address at each label
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
@@ -153,7 +153,7 @@
             self.LGFI(dest_reg, l.imm(word))
         else:
             # this is not put into the constant pool, because it
-            # is an immediate value that cannot easily be estimated
+            # is an immediate value that cannot easily be forseen
             self.LGFI(dest_reg, l.imm(word & 0xFFFFffff))
             self.IIHF(dest_reg, l.imm((word >> 32) & 0xFFFFffff))
 
diff --git a/rpython/jit/backend/zarch/opassembler.py b/rpython/jit/backend/zarch/opassembler.py
--- a/rpython/jit/backend/zarch/opassembler.py
+++ b/rpython/jit/backend/zarch/opassembler.py
@@ -410,3 +410,10 @@
     emit_same_as_f = _genop_same_as
     emit_cast_ptr_to_int = _genop_same_as
     emit_cast_int_to_ptr = _genop_same_as
+
+    def emit_increment_debug_counter(self, op, arglocs, regalloc):
+        addr, scratch = arglocs
+        self.mc.LG(scratch, l.addr(0,addr))
+        self.mc.AGHI(scratch, l.imm(1))
+        self.mc.STG(scratch, l.addr(0,addr))
+
diff --git a/rpython/jit/backend/zarch/regalloc.py b/rpython/jit/backend/zarch/regalloc.py
--- a/rpython/jit/backend/zarch/regalloc.py
+++ b/rpython/jit/backend/zarch/regalloc.py
@@ -609,12 +609,24 @@
                 if loc is not None and loc.is_stack():
                     self.fm.hint_frame_pos[box] = self.fm.get_loc_index(loc)
 
+    def convert_to_int(self, c):
+        if isinstance(c, ConstInt):
+            return rffi.cast(lltype.Signed, c.value)
+        else:
+            assert isinstance(c, ConstPtr)
+            return rffi.cast(lltype.Signed, c.value)
+
     # ******************************************************
     # *         P R E P A R E  O P E R A T I O N S         * 
     # ******************************************************
 
     def prepare_increment_debug_counter(self, op):
-        pass # XXX
+        #poolloc = self.ensure_reg(op.getarg(0))
+        immvalue = self.convert_to_int(op.getarg(0))
+        base_loc = r.SCRATCH
+        self.assembler.mc.load_imm(base_loc, immvalue)
+        scratch = r.SCRATCH2
+        return [base_loc, scratch]
 
     prepare_int_add = helper.prepare_int_add
     prepare_int_add_ovf = helper.prepare_int_add


More information about the pypy-commit mailing list