Type Type::get_array_to_with_region(Nodecl::NodeclBase lower_bound, Nodecl::NodeclBase upper_bound, Nodecl::NodeclBase region_lower_bound, Nodecl::NodeclBase region_upper_bound, Scope sc) { type_t* result_type = this->_type_info; const decl_context_t* decl_context = sc.get_decl_context(); // Make the range of the region Nodecl::NodeclBase range = Nodecl::Range::make( region_lower_bound, region_upper_bound, const_value_to_nodecl(const_value_get_one(4, 1)), region_lower_bound.get_type(), region_lower_bound.get_locus()); type_t* array_to = get_array_type_bounds_with_regions( result_type, lower_bound.get_internal_nodecl(), upper_bound.get_internal_nodecl(), decl_context, range.get_internal_nodecl(), decl_context); return array_to; }
bool ArrayAccessInfoVisitor::unhandled_node( const Nodecl::NodeclBase& n ) { std::cerr << "Unhandled node while parsing Array Subscript '" << codegen_to_str( n.get_internal_nodecl( ), nodecl_retrieve_context( n.get_internal_nodecl( ) ) ) << "' of type '" << ast_print_node_type( n.get_kind( ) ) << "'" << std::endl; return false; }
Type Type::get_array_to_with_descriptor(Nodecl::NodeclBase lower_bound, Nodecl::NodeclBase upper_bound, Scope sc) { type_t* result_type = this->_type_info; const decl_context_t* decl_context = sc.get_decl_context(); type_t* array_to = get_array_type_bounds_with_descriptor(result_type, lower_bound.get_internal_nodecl(), upper_bound.get_internal_nodecl(), decl_context); return Type(array_to); }
static void handle_ompss_opencl_deallocate_intrinsic( Nodecl::FunctionCall function_call, Nodecl::NodeclBase expr_stmt) { Nodecl::List arguments = function_call.get_arguments().as<Nodecl::List>(); ERROR_CONDITION(arguments.size() != 1, "More than one argument in ompss_opencl_deallocate call", 0); Nodecl::NodeclBase actual_argument = arguments[0]; ERROR_CONDITION(!actual_argument.is<Nodecl::FortranActualArgument>(), "Unexpected tree", 0); Nodecl::NodeclBase arg = actual_argument.as<Nodecl::FortranActualArgument>().get_argument(); TL::Symbol array_sym = ::fortran_data_ref_get_symbol(arg.get_internal_nodecl()); ERROR_CONDITION( !(array_sym.get_type().is_fortran_array() && array_sym.is_allocatable()) && !(array_sym.get_type().is_pointer() && array_sym.get_type().points_to().is_fortran_array()), "The argument of 'ompss_opencl_deallocate' intrinsic must be " "an allocatable array or a pointer to an array\n", 0); // Replace the current intrinsic call by a call to the Nanos++ API TL::Symbol ptr_of_arr_sym = get_function_ptr_of(array_sym, expr_stmt.retrieve_context()); TL::Source new_function_call; new_function_call << "CALL NANOS_OPENCL_DEALLOCATE_FORTRAN(" << ptr_of_arr_sym.get_name() << "("<< as_expression(arg) << "))\n" ; expr_stmt.replace(new_function_call.parse_statement(expr_stmt)); }
std::string as_statement(const Nodecl::NodeclBase& n) { std::stringstream ss; ss << nodecl_stmt_to_source(n.get_internal_nodecl()); if (IS_FORTRAN_LANGUAGE) ss << "\n"; return ss.str(); }
Type Type::get_array_to(Nodecl::NodeclBase array_expr, Scope sc) { type_t* result_type = this->_type_info; const decl_context_t* decl_context = sc.get_decl_context(); type_t* array_to = get_array_type(result_type, array_expr.get_internal_nodecl(), decl_context); return Type(array_to); }
void build_empty_body_for_function( TL::Symbol function_symbol, Nodecl::NodeclBase &function_code, Nodecl::NodeclBase &empty_stmt) { empty_stmt = Nodecl::EmptyStatement::make(make_locus("", 0, 0)); Nodecl::List stmt_list = Nodecl::List::make(empty_stmt); if (IS_C_LANGUAGE || IS_CXX_LANGUAGE) { Nodecl::CompoundStatement compound_statement = Nodecl::CompoundStatement::make(stmt_list, /* destructors */ Nodecl::NodeclBase::null(), make_locus("", 0, 0)); stmt_list = Nodecl::List::make(compound_statement); } Nodecl::NodeclBase context = Nodecl::Context::make( stmt_list, function_symbol.get_related_scope(), make_locus("", 0, 0)); function_symbol.get_internal_symbol()->defined = 1; if (function_symbol.is_dependent_function()) { function_code = Nodecl::TemplateFunctionCode::make(context, // Initializers Nodecl::NodeclBase::null(), function_symbol, make_locus("", 0, 0)); } else { function_code = Nodecl::FunctionCode::make(context, // Initializers Nodecl::NodeclBase::null(), function_symbol, make_locus("", 0, 0)); } function_symbol.get_internal_symbol()->entity_specs.function_code = function_code.get_internal_nodecl(); }
void Symbol::set_value(Nodecl::NodeclBase n) { _symbol->value = n.get_internal_nodecl(); }
std::string as_expression(const Nodecl::NodeclBase& n) { ERROR_CONDITION (n.is_null(), "Cannot create a literal expression from a null node", 0); return nodecl_expr_to_source(n.get_internal_nodecl()); }
UNUSED_PARAMETER static void print_ast_dot(const Nodecl::NodeclBase &node) { std::cerr << std::endl << std::endl; ast_dump_graphviz(nodecl_get_ast(node.get_internal_nodecl()), stderr); std::cerr << std::endl << std::endl; }
static void handle_ompss_opencl_allocate_intrinsic( Nodecl::FunctionCall function_call, std::map<std::pair<TL::Type, std::pair<int, bool> > , Symbol> &declared_ocl_allocate_functions, Nodecl::NodeclBase expr_stmt) { Nodecl::List arguments = function_call.get_arguments().as<Nodecl::List>(); ERROR_CONDITION(arguments.size() != 1, "More than one argument in 'ompss_opencl_allocate' call\n", 0); Nodecl::NodeclBase actual_argument = arguments[0]; ERROR_CONDITION(!actual_argument.is<Nodecl::FortranActualArgument>(), "Unexpected tree\n", 0); Nodecl::NodeclBase arg = actual_argument.as<Nodecl::FortranActualArgument>().get_argument(); ERROR_CONDITION(!arg.is<Nodecl::ArraySubscript>(), "Unreachable code\n", 0); Nodecl::NodeclBase subscripted = arg.as<Nodecl::ArraySubscript>().get_subscripted(); TL::Symbol subscripted_symbol = ::fortran_data_ref_get_symbol(subscripted.get_internal_nodecl()); ERROR_CONDITION( !(subscripted_symbol.get_type().is_fortran_array() && subscripted_symbol.is_allocatable()) && !(subscripted_symbol.get_type().is_pointer() && subscripted_symbol.get_type().points_to().is_fortran_array()), "The argument of 'ompss_opencl_allocate' intrinsic must be " "an allocatable array or a pointer to an array with all its bounds specified\n", 0); TL::Type array_type; int num_dimensions; bool is_allocatable; if (subscripted_symbol.is_allocatable()) { array_type = subscripted_symbol.get_type(); num_dimensions = subscripted_symbol.get_type().get_num_dimensions(); is_allocatable = true; } else { array_type = subscripted_symbol.get_type().points_to(); num_dimensions = array_type.get_num_dimensions(); is_allocatable = false; } TL::Type element_type = array_type; while (element_type.is_array()) { element_type = element_type.array_element(); } ERROR_CONDITION(!array_type.is_array(), "This type should be an array type", 0); std::pair<TL::Type, std::pair<int, bool> > key = std::make_pair(element_type, std::make_pair(num_dimensions, is_allocatable)); std::map<std::pair<TL::Type, std::pair<int, bool> > , Symbol>::iterator it_new_fun = declared_ocl_allocate_functions.find(key); // Reuse the auxiliar function if it already exists Symbol new_function_sym; if (it_new_fun != declared_ocl_allocate_functions.end()) { new_function_sym = it_new_fun->second; } else { new_function_sym = create_new_function_opencl_allocate( expr_stmt, subscripted_symbol, element_type, num_dimensions, is_allocatable); declared_ocl_allocate_functions[key] = new_function_sym; } // Replace the current intrinsic call by a call to the new function TL::Source actual_arg_array; Nodecl::NodeclBase subscripted_lvalue = subscripted.shallow_copy(); subscripted_lvalue.set_type(subscripted_symbol.get_type().no_ref().get_lvalue_reference_to()); actual_arg_array << as_expression(subscripted_lvalue); TL::Source actual_arg_bounds; Nodecl::List subscripts = arg.as<Nodecl::ArraySubscript>().get_subscripts().as<Nodecl::List>(); for (Nodecl::List::reverse_iterator it = subscripts.rbegin(); it != subscripts.rend(); it++) { Nodecl::NodeclBase subscript = *it, lower, upper; if (it != subscripts.rbegin()) actual_arg_bounds << ", "; if (subscript.is<Nodecl::Range>()) { lower = subscript.as<Nodecl::Range>().get_lower(); upper = subscript.as<Nodecl::Range>().get_upper(); } else { lower = nodecl_make_integer_literal( fortran_get_default_integer_type(), const_value_get_signed_int(1), make_locus("", 0, 0)); upper = subscript; } actual_arg_bounds << as_expression(lower) << "," << as_expression(upper); } TL::Source new_function_call; new_function_call << "CALL " << as_symbol(new_function_sym) << "(" << actual_arg_array << ", " << actual_arg_bounds << ")\n" ; expr_stmt.replace(new_function_call.parse_statement(expr_stmt)); }