Commits

Maciej Fijalkowski committed e618293

make assert_aligned a call

  • Participants
  • Parent commits f51969a
  • Branches backend-vector-ops

Comments (0)

Files changed (5)

File pypy/jit/codewriter/effectinfo.py

     OS_LLONG_U_TO_FLOAT         = 94
     #
     OS_MATH_SQRT                = 100
+    #
+    OS_ASSERT_ALIGNED           = 200
 
     # for debugging:
     _OS_CANRAISE = set([OS_NONE, OS_STR2UNICODE, OS_LIBFFI_CALL])

File pypy/jit/metainterp/optimizeopt/fficall.py

         Optimization.emit_operation(self, op)
 
     def optimize_CALL(self, op):
-        oopspec = self._get_oopspec(op)
+        oopspec = self.get_oopspec(op)
         ops = [op]
         if oopspec == EffectInfo.OS_LIBFFI_PREPARE:
             ops = self.do_prepare_call(op)
             debug_print(self.logops.repr_of_resop(op))
         dispatch_opt(self, op)
 
-    def _get_oopspec(self, op):
-        effectinfo = op.getdescr().get_extra_info()
-        return effectinfo.oopspecindex
-
     def _get_funcval(self, op):
         return self.getvalue(op.getarg(1))
 

File pypy/jit/metainterp/optimizeopt/optimizer.py

     def forget_numberings(self, box):
         self.optimizer.forget_numberings(box)
 
+    def get_oopspec(self, op):
+        effectinfo = op.getdescr().get_extra_info()
+        return effectinfo.oopspecindex
 
 class Optimizer(Optimization):
 

File pypy/jit/metainterp/optimizeopt/test/test_vectorize.py

 
 from pypy.jit.metainterp.optimizeopt.test.test_optimizebasic import BaseTestBasic, LLtypeMixin
+from pypy.rpython.lltypesystem import lltype
+from pypy.jit.codewriter.effectinfo import EffectInfo
 
 class TestVectorize(BaseTestBasic, LLtypeMixin):
     enable_opts = "intbounds:rewrite:virtualize:string:earlyforce:pure:heap:unroll:vectorize"
 
+    class namespace:
+        cpu = LLtypeMixin.cpu
+        FUNC = LLtypeMixin.FUNC
+        arraydescr = cpu.arraydescrof(lltype.GcArray(lltype.Signed))
+
+        def calldescr(cpu, FUNC, oopspecindex, extraeffect=None):
+            if extraeffect == EffectInfo.EF_RANDOM_EFFECTS:
+                f = None   # means "can force all" really
+            else:
+                f = []
+            einfo = EffectInfo(f, f, f, f, oopspecindex=oopspecindex,
+                               extraeffect=extraeffect)
+            return cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT, einfo)
+        #
+        assert_aligned =  calldescr(cpu, FUNC, EffectInfo.OS_ASSERT_ALIGNED)
+
+    namespace = namespace.__dict__
+
     def test_basic(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        assert_aligned(p0, i0)
-        assert_aligned(p1, i1)
-        assert_aligned(p1, i2)
+        call(p0, i0, descr=assert_aligned)
+        call(p1, i1, descr=assert_aligned)
+        call(p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
     def test_basic_sub(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        assert_aligned(p0, i0)
-        assert_aligned(p1, i1)
-        assert_aligned(p1, i2)
+        call(p0, i0, descr=assert_aligned)
+        call(p1, i1, descr=assert_aligned)
+        call(p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_sub(f0, f1)
     def test_unfit_trees(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        assert_aligned(p0, i0)
-        assert_aligned(p1, i1)
-        assert_aligned(p1, i2)
+        call(p0, i0, descr=assert_aligned)
+        call(p1, i1, descr=assert_aligned)
+        call(p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
     def test_unfit_trees_2(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        assert_aligned(p0, i0)
-        assert_aligned(p1, i1)
-        assert_aligned(p1, i2)
+        call(p0, i0, descr=assert_aligned)
+        call(p1, i1, descr=assert_aligned)
+        call(p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
     def test_unfit_trees_3(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        assert_aligned(p0, i0)
-        assert_aligned(p1, i1)
-        assert_aligned(p1, i2)
+        call(p0, i0, descr=assert_aligned)
+        call(p1, i1, descr=assert_aligned)
+        call(p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
     def test_guard_forces(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        assert_aligned(p0, i0)
-        assert_aligned(p1, i1)
-        assert_aligned(p1, i2)
+        call(p0, i0, descr=assert_aligned)
+        call(p1, i1, descr=assert_aligned)
+        call(p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)
     def test_guard_prevents(self):
         ops = """
         [p0, p1, p2, i0, i1, i2]
-        assert_aligned(p0, i0)
-        assert_aligned(p1, i1)
-        assert_aligned(p1, i2)
+        call(p0, i0, descr=assert_aligned)
+        call(p1, i1, descr=assert_aligned)
+        call(p1, i2, descr=assert_aligned)
         f0 = getarrayitem_raw(p0, i0, descr=arraydescr)
         f1 = getarrayitem_raw(p1, i1, descr=arraydescr)
         f2 = float_add(f0, f1)

File pypy/jit/metainterp/optimizeopt/vectorize.py

 from pypy.jit.metainterp.optimizeopt.util import make_dispatcher_method
 from pypy.jit.metainterp.resoperation import rop, ResOperation
 from pypy.jit.metainterp.history import BoxVector
+from pypy.jit.codewriter.effectinfo import EffectInfo
 
 VECTOR_SIZE = 2
 VEC_MAP = {rop.FLOAT_ADD: rop.FLOAT_VECTOR_ADD,
     def new(self):
         return OptVectorize()
     
-    def optimize_ASSERT_ALIGNED(self, op):
-        index = self.getvalue(op.getarg(1))
-        self.tracked_indexes[index] = TrackIndex(index, 0)
+    def optimize_CALL(self, op):
+        oopspec = self.get_oopspec(op)
+        if oopspec == EffectInfo.OS_ASSERT_ALIGNED:
+            index = self.getvalue(op.getarg(1))
+            self.tracked_indexes[index] = TrackIndex(index, 0)
+        else:
+            self.optimize_default(op)
 
     def optimize_GETARRAYITEM_RAW(self, op):
         arr = self.getvalue(op.getarg(0))