Author: David Malcolm <[email protected]>
Branch: libgccjit-backend
Changeset: r75085:a2a235719797
Date: 2014-12-23 11:07 -0500
http://bitbucket.org/pypy/pypy/changeset/a2a235719797/
Log: Whitespace cleanups
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
@@ -6,9 +6,11 @@
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.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
+from rpython.rtyper.annlowlevel import (
+ llhelper, cast_instance_to_gcref, cast_object_to_ptr)
from rpython.rtyper.lltypesystem.rffi import *
from rpython.rtyper.lltypesystem import lltype, rffi, rstr, llmemory
@@ -34,10 +36,10 @@
self.rffi_fn = rffi_fn
self.patchpoints = []
- def new_block(self, name):
+ def new_block(self, name):
return self.rffi_fn.new_block(name)
- def new_local(self, type_, name):
+ def new_local(self, type_, name):
return self.rffi_fn.new_local(type_, name)
class Patchpoint:
@@ -69,7 +71,7 @@
0x00007fffeb7086d0 <+16>: jle 0x7fffeb7086c8 <anonloop_0+8>
0x00007fffeb7086d2 <+18>: mov %rax,0x48(%rdi)
- 0x00007fffeb7086d6 <+22>: mov 0x2008fb(%rip),%rax #
0x7fffeb908fd8
+ 0x00007fffeb7086d6 <+22>: mov 0x2008fb(%rip),%rax # 0x7fffeb908fd8
0x00007fffeb7086dd <+29>: mov (%rax),%rax
0x00007fffeb7086e0 <+32>: jmpq *%rax
"""
@@ -77,10 +79,10 @@
self.failure_params = Params(assembler)
self.serial = assembler.num_guard_failure_fns
assembler.num_guard_failure_fns += 1
- self.t_fn_ptr_type = (
- assembler.ctxt.new_function_ptr_type (assembler.t_jit_frame_ptr,
-
self.failure_params.paramtypes,
- r_int(0)))
+ self.t_fn_ptr_type = assembler.ctxt.new_function_ptr_type (
+ assembler.t_jit_frame_ptr,
+ self.failure_params.paramtypes,
+ r_int(0))
# Create the function ptr
# Globals are zero-initialized, so we'll need to
# write in the ptr to the initial handler before the loop is called,
@@ -169,36 +171,44 @@
def make_context(self):
self.ctxt =
Context.acquire(self.lib)#self.lib.gcc_jit_context_acquire()
if 0:
-
self.ctxt.set_bool_option(self.lib.GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE,
- r_int(1))
+ self.ctxt.set_bool_option(
+ self.lib.GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE,
+ r_int(1))
if 0:
-
self.ctxt.set_bool_option(self.lib.GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE,
- r_int(1))
+ self.ctxt.set_bool_option(
+ self.lib.GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE,
+ r_int(1))
if 1:
- self.ctxt.set_bool_option(self.lib.GCC_JIT_BOOL_OPTION_DEBUGINFO,
- r_int(1))
+ self.ctxt.set_bool_option(
+ self.lib.GCC_JIT_BOOL_OPTION_DEBUGINFO,
+ r_int(1))
if 1:
-
self.ctxt.set_int_option(self.lib.GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
- r_int(2))
+ self.ctxt.set_int_option(
+ self.lib.GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
+ r_int(2))
if 1:
-
self.ctxt.set_bool_option(self.lib.GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES,
- r_int(1))
+ self.ctxt.set_bool_option(
+ self.lib.GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES,
+ r_int(1))
if 1:
-
self.ctxt.set_bool_option(self.lib.GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING,
- r_int(1))
+ self.ctxt.set_bool_option(
+ self.lib.GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING,
+ r_int(1))
if 0:
-
self.ctxt.set_bool_option(self.lib.GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE,
- r_int(1))
+ self.ctxt.set_bool_option(
+ self.lib.GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE,
+ r_int(1))
self.t_Signed = self.ctxt.get_int_type(r_int(self.sizeof_signed),
r_int(1))
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
+ self.t_float = self.ctxt.get_type(self.lib.GCC_JIT_TYPE_DOUBLE) # FIXME
self.t_bool = self.ctxt.get_type(self.lib.GCC_JIT_TYPE_BOOL)
self.t_void_ptr = self.ctxt.get_type(self.lib.GCC_JIT_TYPE_VOID_PTR)
self.t_void = self.ctxt.get_type(self.lib.GCC_JIT_TYPE_VOID)
- self.t_char_ptr =
self.ctxt.get_type(self.lib.GCC_JIT_TYPE_CHAR).get_pointer()
+ self.t_char_ptr = self.ctxt.get_type(
+ self.lib.GCC_JIT_TYPE_CHAR).get_pointer()
self.u_signed = self.ctxt.new_field(self.t_Signed, "u_signed")
self.u_float = self.ctxt.new_field(self.t_float, "u_float")
@@ -374,12 +384,13 @@
#jitframe.JITFRAMEINFOPTR
self.loop_params = Params(self)
- self.fn = Function(name,
-
self.ctxt.new_function(self.lib.GCC_JIT_FUNCTION_EXPORTED,
- self.t_jit_frame_ptr,
- name,
- self.loop_params.paramlist,
- r_int(0)))
+ self.fn = Function(
+ name,
+ self.ctxt.new_function(self.lib.GCC_JIT_FUNCTION_EXPORTED,
+ self.t_jit_frame_ptr,
+ name,
+ self.loop_params.paramlist,
+ r_int(0)))
self.b_current = self.fn.new_block("initial")
@@ -401,11 +412,13 @@
# (gdb) p *(double*)&jitframe->arg1
# $8 = -2.25
#src_ptr_rvalue = self.get_arg_as_lvalue(idx).get_address()
- #src_ptr_rvalue = self.ctxt.new_cast(src_ptr_rvalue,
self.t_float.get_pointer())
+ #src_ptr_rvalue = self.ctxt.new_cast(src_ptr_rvalue,
+ # self.t_float.get_pointer())
#src_rvalue = self.ctxt.new_dereference(src_ptr_rvalue)
# or do it as a union
field = self.get_union_field_for_expr(arg)
- src_rvalue =
self.get_arg_as_lvalue(idx).access_field(field).as_rvalue()
+ src_rvalue = self.get_arg_as_lvalue(
+ idx).access_field(field).as_rvalue()
# FIXME: this may need a cast:
#src_rvalue = self.ctxt.new_cast(src_rvalue, self.t_float)
self.b_current.add_assignment(
@@ -451,8 +464,9 @@
elif isinstance(expr, ConstFloat):
#print('value: %r' % expr.value)
#print('type(value): %r' % type(expr.value))
- return self.ctxt.new_rvalue_from_double(self.t_float,
-
expr.value)#r_double(expr.value))
+ return self.ctxt.new_rvalue_from_double(
+ self.t_float,
+ expr.value)#r_double(expr.value))
elif isinstance(expr, ConstPtr):
#print('value: %r' % expr.value)
#print('type(value): %r' % type(expr.value))
@@ -482,7 +496,7 @@
"""
if isinstance(expr, (BoxInt, BoxFloat, BoxPtr)):
return self.get_box_as_lvalue(expr)
-
+
raise NotImplementedError('unhandled expr: %s' % expr)
def get_type_for_box(self, box):
@@ -503,7 +517,8 @@
elif isinstance(expr, (BoxPtr, ConstPtr)):
return self.u_ptr;
else:
- raise NotImplementedError('unhandled expr: %s %s' % (expr,
type(expr)))
+ raise NotImplementedError('unhandled expr: %s %s'
+ % (expr, type(expr)))
# Handling of specific ResOperation subclasses: each one is
# a method named "emit_foo", where "foo" is the str() of the resop.
@@ -524,8 +539,8 @@
# We need to write to the boxes listed in the label's args
# with the values from those listed in the jump's args.
- # However, there are potential cases like JUMP(i0, i1) going to
LABEL(i1, i0)
- # where all such assignments happen "simultaneously".
+ # However, there are potential cases like JUMP(i0, i1) going
+ # to LABEL(i1, i0) where all such assignments happen "simultaneously".
# Hence we need to set up temporaries.
# First pass: capture the value of relevant boxes at the JUMP:
tmps = []
@@ -551,11 +566,12 @@
# Sadly, we need to "import" the fn by name, since it was
# created on a different gcc_jit_context.
p = Params(self)
- other_fn =
self.ctxt.new_function(self.lib.GCC_JIT_FUNCTION_IMPORTED,
- self.t_jit_frame_ptr,
- dest_fn.name,
- p.paramlist,
- r_int(0))
+ other_fn = self.ctxt.new_function(
+ self.lib.GCC_JIT_FUNCTION_IMPORTED,
+ self.t_jit_frame_ptr,
+ dest_fn.name,
+ p.paramlist,
+ r_int(0))
args = [param.as_rvalue()
for param in self.loop_params.paramlist]
call = self.ctxt.new_call(other_fn, args)
@@ -564,7 +580,8 @@
def emit_finish(self, resop):
self._impl_write_output_args(self.loop_params, resop._args)
self._impl_write_jf_descr(self.loop_params, resop)
- self.b_current.end_with_return(self.loop_params.param_frame.as_rvalue
())
+ self.b_current.end_with_return(
+ self.loop_params.param_frame.as_rvalue ())
def emit_label(self, resop):
print(resop)
@@ -613,7 +630,8 @@
b_within_failure_fn = pp.failure_fn.new_block("initial")
self.b_current = b_within_failure_fn
self._impl_write_jf_descr(pp.failure_params, resop)
- self.b_current.end_with_return(pp.failure_params.param_frame.as_rvalue
())
+ self.b_current.end_with_return(
+ pp.failure_params.param_frame.as_rvalue ())
rd_locs = []
for idx, arg in enumerate(resop._fail_args):
rd_locs.append(idx * self.sizeof_signed)
@@ -629,7 +647,7 @@
def emit_guard_true(self, resop):
self._impl_bool_guard(resop, r_int(1))
-
+
def emit_guard_false(self, resop):
self._impl_bool_guard(resop, r_int(0))
@@ -922,7 +940,6 @@
self.b_current.add_assignment(
field_lvalue,
-
# ... = ARG1,
self.ctxt.new_cast(self.expr_to_rvalue(resop._arg1),
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
@@ -96,274 +96,284 @@
# Entrypoints:
for returntype, name, paramtypes in [
- (self.GCC_JIT_CONTEXT_P,
- 'gcc_jit_context_acquire', []),
+ (self.GCC_JIT_CONTEXT_P,
+ 'gcc_jit_context_acquire', []),
- (lltype.Void,
- 'gcc_jit_context_release', [self.GCC_JIT_CONTEXT_P]),
+ (lltype.Void,
+ 'gcc_jit_context_release', [self.GCC_JIT_CONTEXT_P]),
- (lltype.Void,
- 'gcc_jit_context_set_int_option', [self.GCC_JIT_CONTEXT_P,
- INT, # FIXME: enum
gcc_jit_int_option opt,
- INT]),
- (lltype.Void,
- 'gcc_jit_context_set_bool_option', [self.GCC_JIT_CONTEXT_P,
- INT, # FIXME: enum
gcc_jit_bool_option opt,
- INT]),
+ (lltype.Void,
+ 'gcc_jit_context_set_int_option', [self.GCC_JIT_CONTEXT_P,
+ # FIXME:
+ # enum gcc_jit_int_option:
+ INT,
+ INT]),
+ (lltype.Void,
+ 'gcc_jit_context_set_bool_option', [self.GCC_JIT_CONTEXT_P,
+ # FIXME:
+ # enum gcc_jit_bool_option:
+ INT,
+ INT]),
- (self.GCC_JIT_RESULT_P,
- 'gcc_jit_context_compile', [self.GCC_JIT_CONTEXT_P]),
+ (self.GCC_JIT_RESULT_P,
+ 'gcc_jit_context_compile', [self.GCC_JIT_CONTEXT_P]),
- (lltype.Void,
- 'gcc_jit_context_dump_to_file', [self.GCC_JIT_CONTEXT_P,
- CCHARP,
- INT]),
-
- (CCHARP,
- 'gcc_jit_context_get_last_error', [self.GCC_JIT_CONTEXT_P]),
-
- (VOIDP,
- 'gcc_jit_result_get_code', [self.GCC_JIT_RESULT_P,
- CCHARP]),
-
- (VOIDP,
- 'gcc_jit_result_get_global', [self.GCC_JIT_RESULT_P,
- CCHARP]),
-
- (lltype.Void,
- 'gcc_jit_result_release', [self.GCC_JIT_RESULT_P]),
-
- (CCHARP,
- 'gcc_jit_object_get_debug_string', [self.GCC_JIT_OBJECT_P]),
-
- ############################################################
- # Types
- ############################################################
- (self.GCC_JIT_TYPE_P,
- 'gcc_jit_context_get_type', [self.GCC_JIT_CONTEXT_P,
+ (lltype.Void,
+ 'gcc_jit_context_dump_to_file', [self.GCC_JIT_CONTEXT_P,
+ CCHARP,
INT]),
- (self.GCC_JIT_TYPE_P,
- 'gcc_jit_context_get_int_type', [self.GCC_JIT_CONTEXT_P,
- INT,
- INT]),
+ (CCHARP,
+ 'gcc_jit_context_get_last_error', [self.GCC_JIT_CONTEXT_P]),
- (self.GCC_JIT_TYPE_P,
- 'gcc_jit_type_get_pointer', [self.GCC_JIT_TYPE_P]),
+ (VOIDP,
+ 'gcc_jit_result_get_code', [self.GCC_JIT_RESULT_P,
+ CCHARP]),
- (self.GCC_JIT_FIELD_P,
- 'gcc_jit_context_new_field', [self.GCC_JIT_CONTEXT_P,
+ (VOIDP,
+ 'gcc_jit_result_get_global', [self.GCC_JIT_RESULT_P,
+ CCHARP]),
+
+ (lltype.Void,
+ 'gcc_jit_result_release', [self.GCC_JIT_RESULT_P]),
+
+ (CCHARP,
+ 'gcc_jit_object_get_debug_string', [self.GCC_JIT_OBJECT_P]),
+
+ ############################################################
+ # Types
+ ############################################################
+ (self.GCC_JIT_TYPE_P,
+ 'gcc_jit_context_get_type', [self.GCC_JIT_CONTEXT_P,
+ INT]),
+
+ (self.GCC_JIT_TYPE_P,
+ 'gcc_jit_context_get_int_type', [self.GCC_JIT_CONTEXT_P,
+ INT,
+ INT]),
+
+ (self.GCC_JIT_TYPE_P,
+ 'gcc_jit_type_get_pointer', [self.GCC_JIT_TYPE_P]),
+
+ (self.GCC_JIT_FIELD_P,
+ 'gcc_jit_context_new_field', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ self.GCC_JIT_TYPE_P,
+ CCHARP]),
+ (self.GCC_JIT_STRUCT_P,
+ 'gcc_jit_context_new_struct_type', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ CCHARP,
+ INT,
+ self.FIELD_P_P]),
+
+ (self.GCC_JIT_STRUCT_P,
+ 'gcc_jit_context_new_opaque_struct', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ CCHARP]),
+ (self.GCC_JIT_TYPE_P,
+ 'gcc_jit_struct_as_type', [self.GCC_JIT_STRUCT_P]),
+
+ (lltype.Void,
+ 'gcc_jit_struct_set_fields', [self.GCC_JIT_STRUCT_P,
+ self.GCC_JIT_LOCATION_P,
+ INT,
+ self.FIELD_P_P]),
+
+ (self.GCC_JIT_TYPE_P,
+ 'gcc_jit_context_new_union_type', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ CCHARP,
+ INT,
+ self.FIELD_P_P]),
+
+ (self.GCC_JIT_TYPE_P,
+ 'gcc_jit_context_new_function_ptr_type', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ self.GCC_JIT_TYPE_P,
+ INT,
+ self.TYPE_P_P,
+ INT]),
+
+ ############################################################
+ # Constructing functions.
+ ############################################################
+ (self.GCC_JIT_PARAM_P,
+ 'gcc_jit_context_new_param', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ self.GCC_JIT_TYPE_P,
+ CCHARP]),
+ (self.GCC_JIT_LVALUE_P,
+ 'gcc_jit_param_as_lvalue', [self.GCC_JIT_PARAM_P]),
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_param_as_rvalue', [self.GCC_JIT_PARAM_P]),
+
+ (self.GCC_JIT_FUNCTION_P,
+ 'gcc_jit_context_new_function', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ # FIXME:
+ # enum gcc_jit_function_kind:
+ INT,
+ self.GCC_JIT_TYPE_P,
+ CCHARP,
+ INT,
+ self.PARAM_P_P,
+ INT]),
+
+ (self.GCC_JIT_OBJECT_P,
+ 'gcc_jit_function_as_object', [self.GCC_JIT_FUNCTION_P]),
+
+ (self.GCC_JIT_LVALUE_P,
+ 'gcc_jit_function_new_local', [self.GCC_JIT_FUNCTION_P,
+ self.GCC_JIT_LOCATION_P,
+ self.GCC_JIT_TYPE_P,
+ CCHARP]),
+
+ (self.GCC_JIT_BLOCK_P,
+ 'gcc_jit_function_new_block', [self.GCC_JIT_FUNCTION_P,
+ CCHARP]),
+
+ ############################################################
+ # lvalues, rvalues and expressions.
+ ############################################################
+ (self.GCC_JIT_LVALUE_P,
+ 'gcc_jit_context_new_global', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ # FIXME enum gcc_jit_global_kind:
+ INT,
+ self.GCC_JIT_TYPE_P,
+ CCHARP]),
+
+ (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,
+ self.GCC_JIT_TYPE_P,
+ INT]),
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_context_new_rvalue_from_long', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_TYPE_P,
+ LONG]),
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_context_zero', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_TYPE_P]),
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_context_one', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_TYPE_P]),
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_context_new_rvalue_from_double', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_TYPE_P,
+ DOUBLE]),
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_context_new_rvalue_from_ptr', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_TYPE_P,
+ 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,
+ # FIXME enum gcc_jit_unary_op:
+ INT,
+ self.GCC_JIT_TYPE_P,
+ self.GCC_JIT_RVALUE_P]),
+
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_context_new_binary_op', [self.GCC_JIT_CONTEXT_P,
self.GCC_JIT_LOCATION_P,
+ # FIXME enum gcc_jit_binary_op:
+ INT,
self.GCC_JIT_TYPE_P,
- CCHARP]),
- (self.GCC_JIT_STRUCT_P,
- 'gcc_jit_context_new_struct_type', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_RVALUE_P,
+ self.GCC_JIT_RVALUE_P]),
+
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_context_new_comparison', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ # FIXME enum
gcc_jit_comparison:
+ INT,
+ self.GCC_JIT_RVALUE_P,
+ self.GCC_JIT_RVALUE_P]),
+
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_context_new_call', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ self.GCC_JIT_FUNCTION_P,
+ INT,
+ self.RVALUE_P_P]),
+
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_context_new_call_through_ptr',[self.GCC_JIT_CONTEXT_P,
self.GCC_JIT_LOCATION_P,
- CCHARP,
+ self.GCC_JIT_RVALUE_P,
INT,
- self.FIELD_P_P]),
+ self.RVALUE_P_P]),
- (self.GCC_JIT_STRUCT_P,
- 'gcc_jit_context_new_opaque_struct', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_LOCATION_P,
- CCHARP]),
- (self.GCC_JIT_TYPE_P,
- 'gcc_jit_struct_as_type', [self.GCC_JIT_STRUCT_P]),
-
- (lltype.Void,
- 'gcc_jit_struct_set_fields', [self.GCC_JIT_STRUCT_P,
- self.GCC_JIT_LOCATION_P,
- INT,
- self.FIELD_P_P]),
-
- (self.GCC_JIT_TYPE_P,
- 'gcc_jit_context_new_union_type', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_LOCATION_P,
- CCHARP,
- INT,
- self.FIELD_P_P]),
-
- (self.GCC_JIT_TYPE_P,
- 'gcc_jit_context_new_function_ptr_type',
[self.GCC_JIT_CONTEXT_P,
-
self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_TYPE_P,
- INT,
- self.TYPE_P_P,
- INT]),
-
- ############################################################
- # Constructing functions.
- ############################################################
- (self.GCC_JIT_PARAM_P,
- 'gcc_jit_context_new_param', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_TYPE_P,
- CCHARP]),
- (self.GCC_JIT_LVALUE_P,
- 'gcc_jit_param_as_lvalue', [self.GCC_JIT_PARAM_P]),
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_param_as_rvalue', [self.GCC_JIT_PARAM_P]),
-
- (self.GCC_JIT_FUNCTION_P,
- 'gcc_jit_context_new_function', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_LOCATION_P,
- INT, # enum
gcc_jit_function_kind kind,
- self.GCC_JIT_TYPE_P,
- CCHARP,
- INT,
- self.PARAM_P_P,
- INT]),
-
- (self.GCC_JIT_OBJECT_P,
- 'gcc_jit_function_as_object', [self.GCC_JIT_FUNCTION_P]),
-
- (self.GCC_JIT_LVALUE_P,
- 'gcc_jit_function_new_local', [self.GCC_JIT_FUNCTION_P,
- self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_TYPE_P,
- CCHARP]),
-
- (self.GCC_JIT_BLOCK_P,
- 'gcc_jit_function_new_block', [self.GCC_JIT_FUNCTION_P,
- CCHARP]),
-
- ############################################################
- # lvalues, rvalues and expressions.
- ############################################################
- (self.GCC_JIT_LVALUE_P,
- 'gcc_jit_context_new_global', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_LOCATION_P,
- INT, # enum gcc_jit_global_kind
- self.GCC_JIT_TYPE_P,
- CCHARP]),
-
- (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,
- self.GCC_JIT_TYPE_P,
- INT]),
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_context_new_rvalue_from_long',
[self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_TYPE_P,
- LONG]),
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_context_zero', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_TYPE_P]),
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_context_one', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_TYPE_P]),
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_context_new_rvalue_from_double',
[self.GCC_JIT_CONTEXT_P,
-
self.GCC_JIT_TYPE_P,
- DOUBLE]),
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_context_new_rvalue_from_ptr',
[self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_TYPE_P,
- VOIDP]),
-
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_context_null', [self.GCC_JIT_CONTEXT_P,
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_context_new_cast', [self.GCC_JIT_CONTEXT_P,
+ self.GCC_JIT_LOCATION_P,
+ self.GCC_JIT_RVALUE_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_LVALUE_P,
+ 'gcc_jit_context_new_array_access', [self.GCC_JIT_CONTEXT_P,
self.GCC_JIT_LOCATION_P,
- INT, # enum gcc_jit_unary_op
op,
- self.GCC_JIT_TYPE_P,
+ self.GCC_JIT_RVALUE_P,
self.GCC_JIT_RVALUE_P]),
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_context_new_binary_op', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_LOCATION_P,
- INT, # enum
gcc_jit_binary_op op,
- self.GCC_JIT_TYPE_P,
- self.GCC_JIT_RVALUE_P,
- self.GCC_JIT_RVALUE_P]),
+ (self.GCC_JIT_LVALUE_P,
+ 'gcc_jit_lvalue_access_field', [self.GCC_JIT_LVALUE_P,
+ self.GCC_JIT_LOCATION_P,
+ self.GCC_JIT_FIELD_P]),
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_context_new_comparison', [self.GCC_JIT_CONTEXT_P,
+ (self.GCC_JIT_LVALUE_P,
+ 'gcc_jit_rvalue_dereference_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', [self.GCC_JIT_RVALUE_P,
+ self.GCC_JIT_LOCATION_P]),
+
+ (self.GCC_JIT_RVALUE_P,
+ 'gcc_jit_lvalue_get_address', [self.GCC_JIT_LVALUE_P,
+ self.GCC_JIT_LOCATION_P]),
+
+ ############################################################
+ # Statement-creation.
+ ############################################################
+ (lltype.Void,
+ 'gcc_jit_block_add_assignment', [self.GCC_JIT_BLOCK_P,
+ self.GCC_JIT_LOCATION_P,
+ self.GCC_JIT_LVALUE_P,
+ self.GCC_JIT_RVALUE_P]),
+ (lltype.Void,
+ 'gcc_jit_block_add_comment', [self.GCC_JIT_BLOCK_P,
+ self.GCC_JIT_LOCATION_P,
+ CCHARP]),
+ (lltype.Void,
+ 'gcc_jit_block_end_with_conditional', [self.GCC_JIT_BLOCK_P,
self.GCC_JIT_LOCATION_P,
- INT, # enum
gcc_jit_comparison op,
self.GCC_JIT_RVALUE_P,
- self.GCC_JIT_RVALUE_P]),
-
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_context_new_call', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_FUNCTION_P,
- INT,
- self.RVALUE_P_P]),
-
- (self.GCC_JIT_RVALUE_P,
-
'gcc_jit_context_new_call_through_ptr',[self.GCC_JIT_CONTEXT_P,
-
self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_RVALUE_P,
- INT,
- self.RVALUE_P_P]),
-
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_context_new_cast', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_RVALUE_P,
- self.GCC_JIT_TYPE_P]),
-
- (self.GCC_JIT_LVALUE_P,
- 'gcc_jit_context_new_array_access', [self.GCC_JIT_CONTEXT_P,
- self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_RVALUE_P,
- self.GCC_JIT_RVALUE_P]),
-
- (self.GCC_JIT_LVALUE_P,
- 'gcc_jit_lvalue_access_field', [self.GCC_JIT_LVALUE_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,
- self.GCC_JIT_FIELD_P]),
-
- (self.GCC_JIT_LVALUE_P,
- 'gcc_jit_rvalue_dereference', [self.GCC_JIT_RVALUE_P,
- self.GCC_JIT_LOCATION_P]),
-
- (self.GCC_JIT_RVALUE_P,
- 'gcc_jit_lvalue_get_address', [self.GCC_JIT_LVALUE_P,
- self.GCC_JIT_LOCATION_P]),
-
- ############################################################
- # Statement-creation.
- ############################################################
- (lltype.Void,
- 'gcc_jit_block_add_assignment', [self.GCC_JIT_BLOCK_P,
- self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_LVALUE_P,
- self.GCC_JIT_RVALUE_P]),
- (lltype.Void,
- 'gcc_jit_block_add_comment', [self.GCC_JIT_BLOCK_P,
+ self.GCC_JIT_BLOCK_P,
+ self.GCC_JIT_BLOCK_P]),
+ (lltype.Void,
+ 'gcc_jit_block_end_with_jump', [self.GCC_JIT_BLOCK_P,
+ self.GCC_JIT_LOCATION_P,
+ self.GCC_JIT_BLOCK_P]),
+ (lltype.Void,
+ 'gcc_jit_block_end_with_return', [self.GCC_JIT_BLOCK_P,
self.GCC_JIT_LOCATION_P,
- CCHARP]),
- (lltype.Void,
- 'gcc_jit_block_end_with_conditional', [self.GCC_JIT_BLOCK_P,
-
self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_RVALUE_P,
- self.GCC_JIT_BLOCK_P,
- self.GCC_JIT_BLOCK_P]),
- (lltype.Void,
- 'gcc_jit_block_end_with_jump', [self.GCC_JIT_BLOCK_P,
- self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_BLOCK_P]),
- (lltype.Void,
- 'gcc_jit_block_end_with_return', [self.GCC_JIT_BLOCK_P,
- self.GCC_JIT_LOCATION_P,
- self.GCC_JIT_RVALUE_P]),
+ self.GCC_JIT_RVALUE_P]),
]:
self.add_entrypoint(returntype, name, paramtypes)
@@ -545,13 +555,13 @@
lltype.free(field_array, flavor='raw')
free_charp(name_charp)
return Struct(self.lib, self, inner_struct)
-
+
def new_opaque_struct(self, name):
name_charp = str2charp(name)
- inner_struct = (
- self.lib.gcc_jit_context_new_opaque_struct(self.inner_ctxt,
-
self.lib.null_location_ptr,
- name_charp))
+ inner_struct = self.lib.gcc_jit_context_new_opaque_struct(
+ self.inner_ctxt,
+ self.lib.null_location_ptr,
+ name_charp)
free_charp(name_charp)
return Struct(self.lib, self, inner_struct)
@@ -579,12 +589,13 @@
for i in range(len(param_types)):
raw_type_array[i] = param_types[i].inner_type
- type_ = self.lib.gcc_jit_context_new_function_ptr_type(self.inner_ctxt,
-
self.lib.null_location_ptr,
-
returntype.inner_type,
-
r_int(len(param_types)),
- raw_type_array,
- is_variadic)
+ type_ = self.lib.gcc_jit_context_new_function_ptr_type(
+ self.inner_ctxt,
+ self.lib.null_location_ptr,
+ returntype.inner_type,
+ r_int(len(param_types)),
+ raw_type_array,
+ is_variadic)
lltype.free(raw_type_array, flavor='raw')
return Type(self.lib, self, type_)
@@ -592,30 +603,34 @@
def new_rvalue_from_int(self, type_, llvalue):
return RValue(self.lib,
self,
-
self.lib.gcc_jit_context_new_rvalue_from_int(self.inner_ctxt,
-
type_.inner_type,
- llvalue))
+ self.lib.gcc_jit_context_new_rvalue_from_int(
+ self.inner_ctxt,
+ type_.inner_type,
+ llvalue))
def new_rvalue_from_long(self, type_, llvalue):
return RValue(self.lib,
self,
-
self.lib.gcc_jit_context_new_rvalue_from_long(self.inner_ctxt,
-
type_.inner_type,
- llvalue))
+ self.lib.gcc_jit_context_new_rvalue_from_long(
+ self.inner_ctxt,
+ type_.inner_type,
+ llvalue))
def new_rvalue_from_double(self, type_, llvalue):
return RValue(self.lib,
self,
-
self.lib.gcc_jit_context_new_rvalue_from_double(self.inner_ctxt,
-
type_.inner_type,
- llvalue))
+ self.lib.gcc_jit_context_new_rvalue_from_double(
+ self.inner_ctxt,
+ type_.inner_type,
+ llvalue))
def new_rvalue_from_ptr(self, type_, llvalue):
return RValue(self.lib,
self,
-
self.lib.gcc_jit_context_new_rvalue_from_ptr(self.inner_ctxt,
-
type_.inner_type,
- llvalue))
+ self.lib.gcc_jit_context_new_rvalue_from_ptr(
+ self.inner_ctxt,
+ type_.inner_type,
+ llvalue))
def null(self, pointer_type):
@@ -627,28 +642,31 @@
def new_unary_op(self, op, type_, rvalue):
return RValue(self.lib,
self,
- self.lib.gcc_jit_context_new_unary_op(self.inner_ctxt,
-
self.lib.null_location_ptr,
- op,
- type_.inner_type,
-
rvalue.inner_rvalue))
+ self.lib.gcc_jit_context_new_unary_op(
+ self.inner_ctxt,
+ self.lib.null_location_ptr,
+ op,
+ type_.inner_type,
+ rvalue.inner_rvalue))
def new_binary_op(self, op, type_, a, b):
return RValue(self.lib,
self,
- self.lib.gcc_jit_context_new_binary_op(self.inner_ctxt,
-
self.lib.null_location_ptr,
- op,
- type_.inner_type,
- a.inner_rvalue,
b.inner_rvalue))
+ self.lib.gcc_jit_context_new_binary_op(
+ self.inner_ctxt,
+ self.lib.null_location_ptr,
+ op,
+ type_.inner_type,
+ a.inner_rvalue, b.inner_rvalue))
def new_comparison(self, op, a, b):
return RValue(self.lib,
self,
- self.lib.gcc_jit_context_new_comparison(self.inner_ctxt,
-
self.lib.null_location_ptr,
- op,
- a.inner_rvalue,
b.inner_rvalue))
+ self.lib.gcc_jit_context_new_comparison(
+ self.inner_ctxt,
+ self.lib.null_location_ptr,
+ op,
+ a.inner_rvalue, b.inner_rvalue))
def new_call(self, fn, args):
raw_arg_array = lltype.malloc(self.lib.RVALUE_P_P.TO,
@@ -670,11 +688,12 @@
flavor='raw') # of maybe gc?
for i in range(len(args)):
raw_arg_array[i] = args[i].inner_rvalue
- rvalue = self.lib.gcc_jit_context_new_call_through_ptr(self.inner_ctxt,
-
self.lib.null_location_ptr,
-
fn_ptr.inner_rvalue,
-
r_int(len(args)),
- raw_arg_array)
+ rvalue = self.lib.gcc_jit_context_new_call_through_ptr(
+ self.inner_ctxt,
+ self.lib.null_location_ptr,
+ fn_ptr.inner_rvalue,
+ r_int(len(args)),
+ raw_arg_array)
lltype.free(raw_arg_array, flavor='raw')
return RValue(self.lib, self, rvalue)
@@ -720,11 +739,12 @@
def new_cast(self, rvalue, type_):
return RValue(self.lib,
- self,
- self.lib.gcc_jit_context_new_cast(self.inner_ctxt,
-
self.lib.null_location_ptr,
- rvalue.inner_rvalue,
- type_.inner_type))
+ self,
+ self.lib.gcc_jit_context_new_cast(
+ self.inner_ctxt,
+ self.lib.null_location_ptr,
+ rvalue.inner_rvalue,
+ type_.inner_type))
def new_array_access(self, ptr, index):
return LValue(self.lib,
@@ -737,7 +757,8 @@
class LibgccjitError(Exception):
def __init__(self, ctxt):
- self.msg = charp2str(ctxt.lib.gcc_jit_context_get_last_error
(ctxt.inner_ctxt))
+ self.msg = charp2str(ctxt.lib.gcc_jit_context_get_last_error (
+ ctxt.inner_ctxt))
#print('self.msg: %r' % self.msg)
def __str__(self):
@@ -757,7 +778,7 @@
def get_pointer(self):
return Type(self.lib,
- self,
+ self,
self.lib.gcc_jit_type_get_pointer(self.inner_type))
class Field(Object):
@@ -772,7 +793,7 @@
def as_type(self):
return Type(self.lib,
- self,
+ self,
self.lib.gcc_jit_struct_as_type(self.inner_struct))
@@ -801,9 +822,10 @@
def dereference_field(self, field):
return LValue(self.lib,
self,
-
self.lib.gcc_jit_rvalue_dereference_field(self.inner_rvalue,
-
self.lib.null_location_ptr,
-
field.inner_field))
+ self.lib.gcc_jit_rvalue_dereference_field(
+ self.inner_rvalue,
+ self.lib.null_location_ptr,
+ field.inner_field))
def dereference(self):
return LValue(self.lib,
@@ -825,9 +847,10 @@
def access_field(self, field):
return LValue(self.lib,
self,
- self.lib.gcc_jit_lvalue_access_field (self.inner_lvalue,
-
self.lib.null_location_ptr,
- field.inner_field))
+ self.lib.gcc_jit_lvalue_access_field (
+ self.inner_lvalue,
+ self.lib.null_location_ptr,
+ field.inner_field))
def get_address(self):
return RValue(self.lib,
diff --git a/rpython/jit/backend/libgccjit/test/test_rffi_bindings.py
b/rpython/jit/backend/libgccjit/test/test_rffi_bindings.py
--- a/rpython/jit/backend/libgccjit/test/test_rffi_bindings.py
+++ b/rpython/jit/backend/libgccjit/test/test_rffi_bindings.py
@@ -34,7 +34,8 @@
assert xf() == 3
"""
-from rpython.jit.backend.libgccjit.rffi_bindings import make_eci, Library,
make_param_array, Context
+from rpython.jit.backend.libgccjit.rffi_bindings import (
+ make_eci, Library, make_param_array, Context)
def test_compile_empty_context():
eci = make_eci()
@@ -46,7 +47,7 @@
result = lib.gcc_jit_context_compile(ctxt)
lib.gcc_jit_context_release(ctxt)
lib.gcc_jit_result_release(result)
-
+
f1 = compile_c(f, [], backendopt=False)
f1 ()
#assert False # to see stderr
@@ -62,21 +63,26 @@
def f():
ctxt = lib.gcc_jit_context_acquire()
- lib.gcc_jit_context_set_bool_option(ctxt,
-
lib.GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE,
- r_int(1))
- lib.gcc_jit_context_set_int_option(ctxt,
-
lib.GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
- r_int(3))
- lib.gcc_jit_context_set_bool_option(ctxt,
-
lib.GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES,
- r_int(1))
- lib.gcc_jit_context_set_bool_option(ctxt,
-
lib.GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING,
- r_int(1))
- lib.gcc_jit_context_set_bool_option(ctxt,
-
lib.GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE,
- r_int(1))
+ lib.gcc_jit_context_set_bool_option(
+ ctxt,
+ lib.GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE,
+ r_int(1))
+ lib.gcc_jit_context_set_int_option(
+ ctxt,
+ lib.GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
+ r_int(3))
+ lib.gcc_jit_context_set_bool_option(
+ ctxt,
+ lib.GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES,
+ r_int(1))
+ lib.gcc_jit_context_set_bool_option(
+ ctxt,
+ lib.GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING,
+ r_int(1))
+ lib.gcc_jit_context_set_bool_option(
+ ctxt,
+ lib.GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE,
+ r_int(1))
t_int = lib.gcc_jit_context_get_type(ctxt, lib.GCC_JIT_TYPE_INT)
param_name = str2charp("input")
param = lib.gcc_jit_context_new_param(ctxt,
@@ -87,7 +93,7 @@
# FIXME: how to build an array of params at this level?
# see liststr2charpp in rffi.py
-
+
fn_name = str2charp("add_one_to")
param_array = make_param_array(lib, [param])
fn = lib.gcc_jit_context_new_function(ctxt,
@@ -109,12 +115,13 @@
b_initial = lib.gcc_jit_function_new_block(fn, block_name)
free_charp(block_name)
c_one = lib.gcc_jit_context_new_rvalue_from_int(ctxt, t_int, r_int(1))
- op_add = lib.gcc_jit_context_new_binary_op(ctxt,
- lib.null_location_ptr,
- lib.GCC_JIT_BINARY_OP_PLUS,
- t_int,
-
lib.gcc_jit_param_as_rvalue(param),
- c_one)
+ op_add = lib.gcc_jit_context_new_binary_op(
+ ctxt,
+ lib.null_location_ptr,
+ lib.GCC_JIT_BINARY_OP_PLUS,
+ t_int,
+ lib.gcc_jit_param_as_rvalue(param),
+ c_one)
lib.gcc_jit_block_add_assignment(b_initial, lib.null_location_ptr,
v_res,
op_add)
@@ -153,7 +160,7 @@
lib.gcc_jit_result_release(jit_result)
return int(fn_result)
-
+
f1 = compile_c(f, [], backendopt=False)
assert f1() == 42
assert False # to see stderr
@@ -222,10 +229,10 @@
jit_result.release()
return int(fn_result)
-
+
f1 = compile_c(f, [], backendopt=False)
assert f1() == 42
assert False # to see stderr
-
+
# TODO: test of an error
# should turn it into an exception, and capture the error
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit