/* Print a statement for copying an array to or from the device, * or for initializing or clearing the device. * The statement identifier of a copying node is called * "to_device_<array name>" or "from_device_<array name>" and * its user pointer points to the gpu_array_info of the array * that needs to be copied. * The node for initializing the device is called "init_device". * The node for clearing the device is called "clear_device". * * Extract the array (if any) from the identifier and call * init_device, clear_device, copy_array_to_device or copy_array_from_device. */ static __isl_give isl_printer *print_device_node(__isl_take isl_printer *p, __isl_keep isl_ast_node *node, struct gpu_prog *prog) { isl_ast_expr *expr, *arg; isl_id *id; const char *name; struct gpu_array_info *array; expr = isl_ast_node_user_get_expr(node); arg = isl_ast_expr_get_op_arg(expr, 0); id = isl_ast_expr_get_id(arg); name = isl_id_get_name(id); array = isl_id_get_user(id); isl_id_free(id); isl_ast_expr_free(arg); isl_ast_expr_free(expr); if (!name) return isl_printer_free(p); if (!strcmp(name, "init_device")) return init_device(p, prog); if (!strcmp(name, "clear_device")) return clear_device(p, prog); if (!array) return isl_printer_free(p); if (!prefixcmp(name, "to_device")) return copy_array_to_device(p, array); else return copy_array_from_device(p, array); }
void cpp_from_isl::process_user(isl_ast_node *node) { auto ast_expr = isl_ast_node_user_get_expr(node); m_is_user_stmt = true; auto expr = process_expr(ast_expr); m_is_user_stmt = false; if (expr) m_ctx->add(expr); isl_ast_expr_free(ast_expr); }
instruction_list * isl_user_to_noclock (isl_ast_node * user_node) { isl_ast_expr * expr = isl_ast_node_user_get_expr (user_node); instruction * user = instruction_alloc (); user->type = INSTR_CALL; user->content.call.identifier = strdup (isl_id_get_name ( isl_ast_expr_get_id (isl_ast_expr_get_op_arg (expr, 0)))); for (int i = 1; i < isl_ast_expr_get_op_n_arg (expr); ++i) { expression_list * e = expression_list_alloc (); e->element = isl_expr_to_noclock_expr (isl_ast_expr_get_op_arg (expr, i)); e->next = NULL; user->content.call.arguments = expression_list_cat ( user->content.call.arguments, e); } instruction_list * list = instruction_list_alloc (); list->element = user; list->next = NULL; return list; }