def visit_PointerCast(self, o): """ Build cgen pointer casts for an :class:`Object`. """ ctype = ctypes_to_C(o.object.dtype) lvalue = c.Pointer(c.Value(ctype, o.object.name)) rvalue = '(%s*) %s' % (ctype, '_%s' % o.object.name) return c.Initializer(lvalue, rvalue)
def _args_cast(self, args): """Build cgen type casts for an iterable of :class:`Argument`.""" ret = [] for i in args: if i.is_TensorArgument: align = "__attribute__((aligned(64)))" shape = ''.join( ["[%s]" % ccode(j) for j in i.provider.symbolic_shape[1:]]) lvalue = c.POD(i.dtype, '(*restrict %s)%s %s' % (i.name, shape, align)) rvalue = '(%s (*)%s) %s' % (c.dtype_to_ctype( i.dtype), shape, '%s_vec' % i.name) ret.append(c.Initializer(lvalue, rvalue)) elif i.is_PtrArgument: ctype = ctypes_to_C(i.dtype) lvalue = c.Pointer(c.Value(ctype, i.name)) rvalue = '(%s*) %s' % (ctype, '_%s' % i.name) ret.append(c.Initializer(lvalue, rvalue)) return ret
def ctype(self): return ctypes_to_C(self.dtype)