[pypy-commit] pypy libgccjit-backend: Get test_cast_int_to_ptr and test_cast_ptr_to_int to pass
dmalcolm
noreply at buildbot.pypy.org
Tue Dec 23 22:27:39 CET 2014
Author: David Malcolm <dmalcolm at redhat.com>
Branch: libgccjit-backend
Changeset: r75093:4c394d19f7b9
Date: 2014-12-23 16:25 -0500
http://bitbucket.org/pypy/pypy/changeset/4c394d19f7b9/
Log: Get test_cast_int_to_ptr and test_cast_ptr_to_int 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
@@ -849,7 +849,7 @@
def emit_float_abs(self, resop):
self._impl_float_unaryop(resop, self.lib.GCC_JIT_UNARY_OP_ABS)
- # "CAST_" operations:
+ # "CAST_" operations for "FLOAT":
def emit_cast_float_to_int(self, resop):
rvalue = self.expr_to_rvalue(resop._arg0)
lvalres = self.expr_to_lvalue(resop.result)
@@ -967,6 +967,28 @@
def emit_int_invert(self, resop):
self._impl_int_unaryop(resop, self.lib.GCC_JIT_UNARY_OP_BITWISE_NEGATE)
+ # "CAST_" operations for "INT" vs "PTR":
+ def emit_cast_ptr_to_int(self, resop):
+ rvalue_in = self.expr_to_rvalue(resop._arg0)
+ lvalue_tmp = self.fn.new_local(self.t_any, "tmp")
+ lvalue_result = self.expr_to_lvalue(resop.result)
+ self.b_current.add_assignment(
+ lvalue_tmp.access_field(self.u_ptr),
+ rvalue_in)
+ self.b_current.add_assignment(
+ lvalue_result,
+ lvalue_tmp.as_rvalue().access_field(self.u_signed))
+ def emit_cast_int_to_ptr(self, resop):
+ rvalue_in = self.expr_to_rvalue(resop._arg0)
+ lvalue_tmp = self.fn.new_local(self.t_any, "tmp")
+ lvalue_result = self.expr_to_lvalue(resop.result)
+ self.b_current.add_assignment(
+ lvalue_tmp.access_field(self.u_signed),
+ rvalue_in)
+ self.b_current.add_assignment(
+ lvalue_result,
+ lvalue_tmp.as_rvalue().access_field(self.u_ptr))
+
#
def impl_get_lvalue_at_offset_from_ptr(self, ptr_expr, ll_offset, t_field):
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
@@ -356,6 +356,11 @@
self.GCC_JIT_LOCATION_P,
self.GCC_JIT_FIELD_P]),
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_rvalue_access_field', [self.GCC_JIT_RVALUE_P,
+ self.GCC_JIT_LOCATION_P,
+ self.GCC_JIT_FIELD_P]),
+
(self.GCC_JIT_LVALUE_P,
'gcc_jit_rvalue_dereference_field', [self.GCC_JIT_RVALUE_P,
self.GCC_JIT_LOCATION_P,
@@ -859,6 +864,14 @@
self,
self.lib.gcc_jit_rvalue_get_type(self.inner_rvalue))
+ def access_field(self, field):
+ return RValue(self.lib,
+ self,
+ self.lib.gcc_jit_rvalue_access_field(
+ self.inner_rvalue,
+ self.lib.null_location_ptr,
+ field.inner_field))
+
def dereference_field(self, field):
return LValue(self.lib,
self,
More information about the pypy-commit
mailing list