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

dmalcolm noreply at buildbot.pypy.org
Tue Dec 23 18:56:51 CET 2014


Author: David Malcolm <dmalcolm at redhat.com>
Branch: libgccjit-backend
Changeset: r75089:d0c24c40d739
Date: 2014-12-23 13:04 -0500
http://bitbucket.org/pypy/pypy/changeset/d0c24c40d739/

Log:	Get test_int_operations to pass

	Implement remaining missing operations needed by test_int_operations
	(UINT_ comparisons, unary INT_ ops).

	FWIW, creates 778 loops.

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
@@ -875,7 +875,29 @@
     def emit_int_ge(self, resop):
         self.impl_int_cmp(resop, self.lib.GCC_JIT_COMPARISON_GE)
 
-    #   "UINT" comparisons:  TODO
+    #   "UINT" comparisons:
+    def impl_uint_cmp(self, resop, gcc_jit_comparison):
+        rval0 = self.expr_to_rvalue(resop._arg0)
+        rval1 = self.expr_to_rvalue(resop._arg1)
+        rval0 = self.ctxt.new_cast(rval0, self.t_UINT)
+        rval1 = self.ctxt.new_cast(rval1, self.t_UINT)
+        lvalres = self.expr_to_lvalue(resop.result)
+        resop_cmp = (
+            self.ctxt.new_cast(
+                self.ctxt.new_comparison(gcc_jit_comparison,
+                                         rval0, rval1),
+                self.t_Signed)
+            )
+        self.b_current.add_assignment(lvalres,
+                                      resop_cmp)
+    def emit_uint_lt(self, resop):
+        self.impl_uint_cmp(resop, self.lib.GCC_JIT_COMPARISON_LT)
+    def emit_uint_le(self, resop):
+        self.impl_uint_cmp(resop, self.lib.GCC_JIT_COMPARISON_LE)
+    def emit_uint_gt(self, resop):
+        self.impl_uint_cmp(resop, self.lib.GCC_JIT_COMPARISON_GT)
+    def emit_uint_ge(self, resop):
+        self.impl_uint_cmp(resop, self.lib.GCC_JIT_COMPARISON_GE)
 
     #   "FLOAT" comparisons:
     def impl_float_cmp(self, resop, gcc_jit_comparison):
@@ -904,6 +926,36 @@
     def emit_float_ge(self, resop):
         self.impl_float_cmp(resop, self.lib.GCC_JIT_COMPARISON_GE)
 
+    # Unary "INT" operations:
+    def _impl_int_unaryop(self, resop, gcc_jit_unary_op):
+        rvalue = self.expr_to_rvalue(resop._arg0)
+        lvalres = self.expr_to_lvalue(resop.result)
+        unaryop_expr = self.ctxt.new_unary_op(gcc_jit_unary_op,
+                                              self.t_Signed,
+                                              rvalue)
+        self.b_current.add_assignment(lvalres, unaryop_expr)
+
+    def emit_int_is_zero(self, resop):
+        self._impl_int_unaryop(resop, self.lib.GCC_JIT_UNARY_OP_LOGICAL_NEGATE)
+    def emit_int_is_true(self, resop):
+        rvalarg = self.expr_to_rvalue(resop._arg0)
+        lvalres = self.expr_to_lvalue(resop.result)
+        resop_cmp = (
+            self.ctxt.new_cast(
+                self.ctxt.new_comparison(self.lib.GCC_JIT_COMPARISON_NE,
+                                         rvalarg,
+                                         self.ctxt.zero(self.t_Signed)),
+                self.t_Signed)
+            )
+        self.b_current.add_assignment(lvalres,
+                                      resop_cmp)
+    def emit_int_neg(self, resop):
+        self._impl_int_unaryop(resop, self.lib.GCC_JIT_UNARY_OP_MINUS)
+    def emit_int_invert(self, resop):
+        self._impl_int_unaryop(resop, self.lib.GCC_JIT_UNARY_OP_BITWISE_NEGATE)
+
+    #
+
     def impl_get_lvalue_at_offset_from_ptr(self, ptr_expr, ll_offset, t_field):
         ptr = self.expr_to_rvalue(ptr_expr)
 
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
@@ -633,6 +633,13 @@
                           type_.inner_type,
                           llvalue))
 
+    def zero(self, numeric_type):
+        return RValue(self.lib,
+                      self,
+                      self.lib.gcc_jit_context_zero(
+                          self.inner_ctxt,
+                          numeric_type.inner_type))
+
     def new_rvalue_from_double(self, type_, llvalue):
         return RValue(self.lib,
                       self,


More information about the pypy-commit mailing list