Author: David Malcolm <dmalc...@redhat.com> Branch: libgccjit-backend Changeset: r75247:72cda48c154f Date: 2015-01-05 14:59 -0500 http://bitbucket.org/pypy/pypy/changeset/72cda48c154f/
Log: Get test_increment_debug_counter 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 @@ -192,11 +192,11 @@ self.ctxt.set_int_option( self.lib.GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, r_int(2)) - if 0: + if 1: self.ctxt.set_bool_option( self.lib.GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES, r_int(1)) - if 0: + if 1: self.ctxt.set_bool_option( self.lib.GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING, r_int(1)) @@ -207,6 +207,7 @@ self.t_Signed = self.ctxt.get_int_type(r_int(self.sizeof_signed), r_int(1)) + self.t_signed_ptr = self.t_Signed.get_pointer() self.t_UINT = self.ctxt.get_int_type(r_int(self.sizeof_signed), r_int(0)) self.t_float = self.ctxt.get_type(self.lib.GCC_JIT_TYPE_DOUBLE) # FIXME @@ -218,11 +219,13 @@ self.u_signed = self.ctxt.new_field(self.t_Signed, "u_signed") self.u_float = self.ctxt.new_field(self.t_float, "u_float") - self.u_ptr = self.ctxt.new_field(self.t_void_ptr, "u_ptr") + self.u_void_ptr = self.ctxt.new_field(self.t_void_ptr, "u_void_ptr") + self.u_signed_ptr = self.ctxt.new_field(self.t_signed_ptr, "u_signed_ptr") self.t_any = self.ctxt.new_union_type ("any", [self.u_signed, self.u_float, - self.u_ptr]) + self.u_void_ptr, + self.u_signed_ptr]) def setup(self, looptoken): allblocks = self.get_asmmemmgr_blocks(looptoken) @@ -273,6 +276,8 @@ if 1: self.ctxt.dump_to_file("/tmp/%s.c" % loopname, r_int(1)) + if 0: + self.ctxt.dump_reproducer_to_file("/tmp/reproduce-%s.c" % loopname) #raise foo @@ -534,7 +539,7 @@ elif isinstance(expr, (BoxFloat, ConstFloat)): return self.u_float; elif isinstance(expr, (BoxPtr, ConstPtr)): - return self.u_ptr; + return self.u_void_ptr; else: raise NotImplementedError('unhandled expr: %s %s' % (expr, type(expr))) @@ -980,7 +985,7 @@ 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), + lvalue_tmp.access_field(self.u_void_ptr), rvalue_in) self.b_current.add_assignment( lvalue_result, @@ -994,7 +999,7 @@ rvalue_in) self.b_current.add_assignment( lvalue_result, - lvalue_tmp.as_rvalue().access_field(self.u_ptr)) + lvalue_tmp.as_rvalue().access_field(self.u_void_ptr)) # @@ -1021,6 +1026,9 @@ # + # + # '_ALWAYS_PURE_LAST', # ----- end of always_pure operations ----- + def impl_get_lvalue_at_offset_from_ptr(self, ptr_expr, ll_offset, t_field): ptr = self.expr_to_rvalue(ptr_expr) @@ -1081,6 +1089,25 @@ self.ctxt.new_cast(field_lvalue.as_rvalue(), self.get_type_for_expr(resop.result))) + # '_NOSIDEEFFECT_LAST', # ----- end of no_side_effect operations ----- + + def cast_signed_to_ptr_to_signed(self, rvalue): + tmp = self.fn.new_local(self.t_any, 'tmp') + self.b_current.add_assignment(tmp.access_field(self.u_signed), + rvalue) + return tmp.access_field(self.u_signed_ptr).as_rvalue() + + def emit_increment_debug_counter(self, resop): + # Equivalent of: + # signed *counter; + # (*counter)++; + ptr = self.expr_to_rvalue(resop._arg0) + ptr = self.cast_signed_to_ptr_to_signed(ptr) + self.b_current.add_assignment_op( + ptr.dereference(), + self.lib.GCC_JIT_BINARY_OP_PLUS, + self.ctxt.one(self.t_Signed)) + def emit_setfield_gc(self, resop): #print(repr(resop)) assert isinstance(resop._arg0, (BoxPtr, ConstPtr)) 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 @@ -124,6 +124,10 @@ CCHARP, INT]), + (lltype.Void, + 'gcc_jit_context_dump_reproducer_to_file', [self.GCC_JIT_CONTEXT_P, + CCHARP]), + (CCHARP, 'gcc_jit_context_get_last_error', [self.GCC_JIT_CONTEXT_P]), @@ -383,6 +387,14 @@ self.GCC_JIT_LVALUE_P, self.GCC_JIT_RVALUE_P]), (lltype.Void, + 'gcc_jit_block_add_assignment_op', [self.GCC_JIT_BLOCK_P, + self.GCC_JIT_LOCATION_P, + self.GCC_JIT_LVALUE_P, + # FIXME: + # enum gcc_jit_binary_op: + INT, + self.GCC_JIT_RVALUE_P]), + (lltype.Void, 'gcc_jit_block_add_comment', [self.GCC_JIT_BLOCK_P, self.GCC_JIT_LOCATION_P, CCHARP]), @@ -543,6 +555,12 @@ update_locations) free_charp(path_charp) + def dump_reproducer_to_file(self, path): + path_charp = str2charp(path) + self.lib.gcc_jit_context_dump_reproducer_to_file(self.inner_ctxt, + path_charp) + free_charp(path_charp) + def get_type(self, r_enum): return Type(self.lib, self, @@ -649,6 +667,13 @@ self.inner_ctxt, numeric_type.inner_type)) + def one(self, numeric_type): + return RValue(self.lib, + self, + self.lib.gcc_jit_context_one( + self.inner_ctxt, + numeric_type.inner_type)) + def new_rvalue_from_double(self, type_, llvalue): return RValue(self.lib, self, @@ -810,6 +835,7 @@ raise LibgccjitError(ctxt) Wrapper.__init__(self, lib) self.inner_obj = inner_obj + self.ctxt = ctxt class Type(Object): def __init__(self, lib, ctxt, inner_type): @@ -819,7 +845,7 @@ def get_pointer(self): return Type(self.lib, - self, + self.ctxt, self.lib.gcc_jit_type_get_pointer(self.inner_type)) class Field(Object): @@ -837,7 +863,7 @@ def as_type(self): return Type(self.lib, - self, + self.ctxt, self.lib.gcc_jit_struct_as_type(self.inner_struct)) @@ -861,12 +887,12 @@ def get_type(self): return Type(self.lib, - self, + self.ctxt, self.lib.gcc_jit_rvalue_get_type(self.inner_rvalue)) def access_field(self, field): return RValue(self.lib, - self, + self.ctxt, self.lib.gcc_jit_rvalue_access_field( self.inner_rvalue, self.lib.null_location_ptr, @@ -874,7 +900,7 @@ def dereference_field(self, field): return LValue(self.lib, - self, + self.ctxt, self.lib.gcc_jit_rvalue_dereference_field( self.inner_rvalue, self.lib.null_location_ptr, @@ -882,7 +908,7 @@ def dereference(self): return LValue(self.lib, - self, + self.ctxt, self.lib.gcc_jit_rvalue_dereference( self.inner_rvalue, self.lib.null_location_ptr)) @@ -895,12 +921,12 @@ def as_rvalue(self): return RValue(self.lib, - self, + self.ctxt, self.lib.gcc_jit_lvalue_as_rvalue(self.inner_lvalue)) def access_field(self, field): return LValue(self.lib, - self, + self.ctxt, self.lib.gcc_jit_lvalue_access_field ( self.inner_lvalue, self.lib.null_location_ptr, @@ -908,7 +934,7 @@ def get_address(self): return RValue(self.lib, - self, + self.ctxt, self.lib.gcc_jit_lvalue_get_address( self.inner_lvalue, self.lib.null_location_ptr)) @@ -921,7 +947,7 @@ def as_rvalue(self): return RValue(self.lib, - self, + self.ctxt, self.lib.gcc_jit_param_as_rvalue(self.inner_param)) class Function(Object): @@ -938,7 +964,7 @@ type_.inner_type, name_charp) free_charp(name_charp) - return LValue(self.lib, self, local) + return LValue(self.lib, self.ctxt, local) def new_block(self, name=None): if name is not None: @@ -949,7 +975,7 @@ name_charp) if name_charp: free_charp(name_charp) - return Block(self.lib, self, block) + return Block(self.lib, self.ctxt, block) class Block(Object): def __init__(self, lib, ctxt, inner_block): @@ -964,6 +990,13 @@ lvalue.inner_lvalue, rvalue.inner_rvalue) + def add_assignment_op(self, lvalue, op, rvalue): + self.lib.gcc_jit_block_add_assignment_op(self.inner_block, + self.lib.null_location_ptr, + lvalue.inner_lvalue, + op, + rvalue.inner_rvalue) + def add_comment(self, text): text_charp = str2charp(text) self.lib.gcc_jit_block_add_comment(self.inner_block, _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit