[pypy-commit] pypy libgccjit-backend: Get test_passing_guards to pass

dmalcolm noreply at buildbot.pypy.org
Tue Dec 23 15:41:52 CET 2014


Author: David Malcolm <dmalcolm at redhat.com>
Branch: libgccjit-backend
Changeset: r75082:cf9335135432
Date: 2014-12-23 09:49 -0500
http://bitbucket.org/pypy/pypy/changeset/cf9335135432/

Log:	Get test_passing_guards to pass

diff --git a/rpython/jit/backend/libgccjit/assembler.py b/rpython/jit/backend/libgccjit/assembler.py
--- a/rpython/jit/backend/libgccjit/assembler.py
+++ b/rpython/jit/backend/libgccjit/assembler.py
@@ -3,7 +3,9 @@
 from rpython.jit.backend.llsupport.asmmemmgr import MachineDataBlockWrapper
 from rpython.jit.backend.llsupport.regalloc import FrameManager
 from rpython.jit.backend.model import CompiledLoopToken
-from rpython.jit.backend.libgccjit.rffi_bindings import make_eci, Library, make_param_array, make_field_array, Context, Type
+from rpython.jit.backend.libgccjit.rffi_bindings import (
+    make_eci, Library, make_param_array, make_field_array, Context, Type,
+    RValue)
 from rpython.jit.metainterp.history import BoxInt, ConstInt, BoxFloat, ConstFloat, BoxPtr, ConstPtr
 from rpython.jit.metainterp.resoperation import *
 from rpython.rtyper.annlowlevel import llhelper, cast_instance_to_gcref, cast_object_to_ptr
@@ -572,13 +574,10 @@
 
     # GUARD_*
 
-    def _impl_guard(self, resop, istrue):
-        print(resop)
-        print(resop.__dict__)
+    def _impl_guard(self, resop, istrue, boolval):
+        assert isinstance(boolval, RValue)
         b_true = self.fn.new_block("on_true_at_%s" % resop)
         b_false = self.fn.new_block("on_false_at_%s" % resop)
-        boolval = self.ctxt.new_cast(self.expr_to_rvalue(resop._arg0),
-                                     self.t_bool)
         self.b_current.end_with_conditional(boolval,
                                             b_true, b_false)
 
@@ -616,11 +615,39 @@
         # Further operations go into the guard success block in the original fn:
         self.b_current = b_guard_success
 
+    def _impl_bool_guard(self, resop, istrue):
+        boolval = self.ctxt.new_cast(self.expr_to_rvalue(resop._arg0),
+                                     self.t_bool)
+        self._impl_guard(resop, istrue, boolval)
+
     def emit_guard_true(self, resop):
-        self._impl_guard(resop, r_int(1))
+        self._impl_bool_guard(resop, r_int(1))
         
     def emit_guard_false(self, resop):
-        self._impl_guard(resop, r_int(0))
+        self._impl_bool_guard(resop, r_int(0))
+
+    def emit_guard_value(self, resop):
+        boolval = self.ctxt.new_comparison(
+            self.lib.GCC_JIT_COMPARISON_EQ,
+            self.expr_to_rvalue(resop._arg0),
+            self.expr_to_rvalue(resop._arg1))
+        self._impl_guard(resop, r_int(1), boolval)
+
+    def emit_guard_nonnull(self, resop):
+        ptr_rvalue = self.expr_to_rvalue(resop._arg0)
+        boolval = self.ctxt.new_comparison(
+            self.lib.GCC_JIT_COMPARISON_NE,
+            ptr_rvalue,
+            self.ctxt.null(ptr_rvalue.get_type()))
+        self._impl_guard(resop, r_int(1), boolval)
+
+    def emit_guard_isnull(self, resop):
+        ptr_rvalue = self.expr_to_rvalue(resop._arg0)
+        boolval = self.ctxt.new_comparison(
+            self.lib.GCC_JIT_COMPARISON_EQ,
+            ptr_rvalue,
+            self.ctxt.null(ptr_rvalue.get_type()))
+        self._impl_guard(resop, r_int(1), boolval)
 
     def _impl_write_output_args(self, params, args):
         # Write outputs back:
diff --git a/rpython/jit/backend/libgccjit/rffi_bindings.py b/rpython/jit/backend/libgccjit/rffi_bindings.py
--- a/rpython/jit/backend/libgccjit/rffi_bindings.py
+++ b/rpython/jit/backend/libgccjit/rffi_bindings.py
@@ -241,6 +241,9 @@
                 (self.GCC_JIT_RVALUE_P,
                  'gcc_jit_lvalue_as_rvalue', [self.GCC_JIT_LVALUE_P]),
 
+                (self.GCC_JIT_TYPE_P,
+                 'gcc_jit_rvalue_get_type', [self.GCC_JIT_RVALUE_P]),
+
                 # Integer constants.
                 (self.GCC_JIT_RVALUE_P,
                  'gcc_jit_context_new_rvalue_from_int', [self.GCC_JIT_CONTEXT_P,
@@ -266,6 +269,10 @@
                                                          VOIDP]),
 
                 (self.GCC_JIT_RVALUE_P,
+                 'gcc_jit_context_null', [self.GCC_JIT_CONTEXT_P,
+                                          self.GCC_JIT_TYPE_P]),
+
+                (self.GCC_JIT_RVALUE_P,
                  'gcc_jit_context_new_unary_op', [self.GCC_JIT_CONTEXT_P,
                                                   self.GCC_JIT_LOCATION_P,
                                                   INT, # enum gcc_jit_unary_op op,
@@ -610,6 +617,13 @@
                                                                    type_.inner_type,
                                                                    llvalue))
 
+
+    def null(self, pointer_type):
+        return RValue(self.lib,
+                      self,
+                      self.lib.gcc_jit_context_null(self.inner_ctxt,
+                                                    pointer_type.inner_type))
+
     def new_unary_op(self, op, type_, rvalue):
         return RValue(self.lib,
                       self,
@@ -779,6 +793,11 @@
         Object.__init__(self, lib, ctxt, inner_rvalue)
         self.inner_rvalue = inner_rvalue
 
+    def get_type(self):
+        return Type(self.lib,
+                    self,
+                    self.lib.gcc_jit_rvalue_get_type(self.inner_rvalue))
+
     def dereference_field(self, field):
         return LValue(self.lib,
                       self,


More information about the pypy-commit mailing list