2025-04-25 Thomas Schwinge Backported from trunk: 2024-08-07 Julian Brown Tobias Burnus * gfortran.h (gfc_option_t): Add disable_omp_is_initial_device. * lang.opt (fbuiltin-): Add. * options.cc (gfc_handle_option): Handle -fno-builtin-omp_is_initial_device. * f95-lang.cc (gfc_init_builtin_functions): Handle DEF_GOMP_BUILTIN_COMPILER. * trans-decl.cc (gfc_get_extern_function_decl): Add code to use DEF_GOMP_BUILTIN_COMPILER for 'omp_is_initial_device'. 2025-04-17 Kwok Cheung Yeung * trans-openmp.cc (gfc_omp_deep_mapping_map): Add new argument for vector of newly created iterators. Push new iterators onto the vector. (gfc_omp_deep_mapping_comps): Add new argument for vector of new iterators. Pass argument in calls to gfc_omp_deep_mapping_item and gfc_omp_deep_mapping_comps. (gfc_omp_deep_mapping_item): Add new argument for vector of new iterators. Pass argument in calls to gfc_omp_deep_mapping_map and gfc_omp_deep_mapping_comps. (gfc_omp_deep_mapping_do): Add new argument for vector of new iterators. Pass argument in calls to gfc_omp_deep_mapping_item. (gfc_omp_deep_mapping_cnt): Pass NULL to new argument for gfc_omp_deep_mapping_do. (gfc_omp_deep_mapping): Add new argument for vector of new iterators. Pass argument in calls to gfc_omp_deep_mapping_do. * trans.h (gfc_omp_deep_mapping): Add new argument. 2025-04-17 Kwok Cheung Yeung * trans-openmp.cc (gfc_omp_deep_mapping_map): Remove const from ctx argument. Add arguments for iterators and the statement sequence to go into the iterator loop. Add statement sequence to iterator loop body. Generate iterator loop entries for generated maps, insert the map decls and sizes into the iterator element arrays, replace original decls with the address of the element arrays, and sizes/biases with SIZE_INT. (gfc_omp_deep_mapping_comps): Remove const from ctx. Add argument for iterators. Pass iterators to calls to gfc_omp_deep_mapping_item and gfc_omp_deep_mapping_comps. (gfc_omp_deep_mapping_item): Remove const from ctx. Add argument for iterators. Collect generated side-effect statements and pass to gfc_omp_deep_mapping_map along with the iterators. Pass iterators to gfc_omp_deep_mapping_comps. (gfc_omp_deep_mapping_do): Remove const from ctx. Pass iterators to gfc_omp_deep_mapping_item. (gfc_omp_deep_mapping_cnt): Remove const from ctx. (gfc_omp_deep_mapping): Likewise. * trans.h (gfc_omp_deep_mapping_cnt): Likewise. (gfc_omp_deep_mapping): Likewise. 2025-04-17 Kwok Cheung Yeung * openmp.cc (gfc_omp_instantiate_mapper): Add argument for namespace. Apply namespace to new clauses. Propagate namespace to nested mappers. (gfc_omp_instantiate_mappers): Pass namespace of clause to clauses generated by mappers. 2025-04-17 Kwok Cheung Yeung * trans-openmp.cc (gfc_trans_omp_array_section): Use macros for accessing iterator elements. (handle_iterator): Likewise. (gfc_trans_omp_clauses): Likewise. 2025-04-17 Kwok Cheung Yeung * trans-openmp.cc (gfc_trans_omp_clauses): Disable strided updates when iterators are used in the clause. 2025-04-17 Kwok Cheung Yeung * dump-parse-tree.cc (show_omp_namelist): Add iterator support for OMP_LIST_TO and OMP_LIST_FROM. * match.cc (gfc_free_namelist): Free namespace for OMP_LIST_TO and OMP_LIST_FROM. * openmp.cc (gfc_free_omp_clauses): Free namespace for OMP_LIST_TO and OMP_LIST_FROM. (gfc_match_motion_var_list): Parse 'iterator' modifier. (resolve_omp_clauses): Resolve iterators for OMP_LIST_TO and OMP_LIST_FROM. * trans-openmp.cc (gfc_trans_omp_clauses): Handle iterators in OMP_LIST_TO and OMP_LIST_FROM clauses. Add expressions to iter_block rather than block. 2025-04-17 Kwok Cheung Yeung * dump-parse-tree.cc (show_omp_namelist): Add iterator support for OMP_LIST_MAP. * match.cc (gfc_free_namelist): Free namespace for OMP_LIST_MAP. * openmp.cc (gfc_free_omp_clauses): Free namespace in namelist for OMP_LIST_MAP. (gfc_match_omp_clauses): Parse 'iterator' modifier for 'map' clause. (resolve_omp_clauses): Resolve iterators for OMP_LIST_MAP. * trans-openmp.cc: Include tree-ssa-loop-niter.h. (gfc_trans_omp_array_section): Add iterator argument. Replace instances of iterator variables with the initial value when computing biases. * trans-openmp.cc (gfc_trans_omp_clauses): Handle iterators in OMP_LIST_MAP clauses. Add expressions to iter_block rather than block. Do not apply iterators to firstprivate maps. Pass iterator to gfc_trans_omp_array_section. 2025-04-17 Kwok Cheung Yeung * trans-openmp.cc (gfc_trans_omp_array_section): Use temporaries only when translating OpenACC. 2025-04-17 Kwok Cheung Yeung * gfortran.h (struct gfc_omp_namelist): Move udm field into a new union u3. * match.cc (gfc_free_omp_namelist): Change references to u2.udm to u3.udm. * module.cc (load_omp_udms): Likewise. (write_omp_udm): Likewise. * openmp.cc (gfc_match_motion_var_list): Likewise. (gfc_match_omp_clauses): Likewise. (resolve_omp_clauses): Likewise. (gfc_omp_instantiate_mapper): Likewise. * trans-openmp.cc (gfc_trans_omp_clauses): Likewise. (gfc_find_nested_mappers): Likewise. 2025-03-21 Paul-Antoine Arras Backported from master: 2025-03-21 Paul-Antoine Arras Tobias Burnus * trans-openmp.cc (gfc_trans_omp_clauses): Make OMP_CLAUSE_DESTROY and OMP_CLAUSE_INIT addressable. * types.def (BT_FN_VOID_INT_INT_PTR_PTR_PTR_INT_PTR_INT_PTR_UINT_PTR): New. 2025-03-18 Tobias Burnus Backported from master: 2025-03-15 Tobias Burnus PR fortran/115271 * module.cc (mio_omp_declare_simd_clauses): New, moved from ... (mio_omp_declare_simd): ... here. Update call, write empty '( )' if there is no declare simd but a declare variant. (mio_omp_declare_variant): New. (mio_symbol): Call it. * openmp.cc (gfc_match_omp_context_selector): Add comment about module.cc to TODO note. * trans-stmt.h (gfc_trans_omp_declare_variant): Take additional parent_ns argument. * trans-decl.cc (create_function_arglist, gfc_create_function_decl): Update call. * trans-openmp.cc (gfc_trans_omp_declare_variant): Take new argument, add some special case handling for attr.use_assoc. 2025-02-18 Tobias Burnus Backported from master: 2025-02-17 Tobias Burnus PR fortran/115271 * gfortran.h (gfc_omp_namelist): Change need_device_ptr to adj_args union and add more flags. * openmp.cc (gfc_match_omp_declare_variant, gfc_resolve_omp_declare): For adjust_args, handle need_device_addr and numeric values/ranges besides dummy argument names. (resolve_omp_dispatch): Remove bogus a adjust_args check. * trans-decl.cc (gfc_handle_omp_declare_variant): New. (gfc_generate_module_vars, gfc_generate_function_code): Call it. * trans-openmp.cc (gfc_trans_omp_declare_variant): Handle numeric values/ranges besides dummy argument names. 2025-02-12 Tobias Burnus Backported from master: 2025-02-05 Tobias Burnus PR fortran/118740 * openmp.cc (gfc_match_omp_context_selector, match_omp_metadirective): Change sorry to sorry_at and use gfc_current_locus as location. * trans-openmp.cc (gfc_trans_omp_clauses): Likewise, but use n->where. 2025-02-12 Tobias Burnus Backported from master: 2025-02-05 Tobias Burnus PR fortran/118745 * trans-openmp.cc (gfc_trans_omp_declare_variant): Use append_args_list in the condition for the append_arg location. 2025-01-30 Tobias Burnus Backported from master: 2025-01-30 Tobias Burnus * gfortran.h (gfc_omp_declare_variant): Add append_args_list. * openmp.cc (gfc_parser_omp_clause_init_modifiers): New; splitt of from ... (gfc_match_omp_init): ... here; call it. (gfc_match_omp_declare_variant): Update to handle append_args clause; some syntax handling fixes. * trans-openmp.cc (gfc_trans_omp_declare_variant): Handle append_args clause; add some diagnostic. 2025-01-28 Tobias Burnus Backported from master: 2025-01-16 Tobias Burnus PR fortran/118321 * trans-openmp.cc (gfc_trans_omp_declare_variant): Honor hidden arguments for append_arg's need_device_ptr. 2025-01-28 Tobias Burnus Backported from master: 2025-01-11 Tobias Burnus * gfortran.h: Add OMP_LIST_INTEROP to the unnamed OMP_LIST_ enum. * openmp.cc (gfc_match_omp_variable_list): Add reverse_order boolean argument, defaulting to false. (enum omp_mask2, OMP_DISPATCH_CLAUSES): Add OMP_CLAUSE_INTEROP. (gfc_match_omp_clauses, resolve_omp_clauses): Handle dispatch's 'interop' clause. * trans-decl.cc (gfc_get_extern_function_decl): Use sym->declared_at instead input_location as DECL_SOURCE_LOCATION. * trans-openmp.cc (gfc_trans_omp_clauses): Handle OMP_LIST_INTEROP. 2025-01-28 Tobias Burnus Backported from master: 2025-01-09 Tobias Burnus * types.def (BT_FN_PTRMODE_PTR_INT_PTR): Add. 2025-01-28 Tobias Burnus Backported from master: 2025-01-02 Tobias Burnus * openmp.cc (OMP_DISPATCH_CLAUSES): Add OMP_CLAUSE_HAS_DEVICE_ADDR. 2025-01-28 Tobias Burnus Backported from master: 2024-12-18 Tobias Burnus * trans-openmp.cc (gfc_trans_omp_declare_variant): Fix 1985a02ef74 omission to change the attribute to "omp declare variant variant args" to also accommodate append_args. 2025-01-27 Tobias Burnus Backported from master: 2025-01-16 Tobias Burnus PR fortran/118441 * trans-intrinsic.cc (gfc_get_symbol_for_expr): Use gfc_new_charlen for character-returning functions. 2025-01-27 Tobias Burnus Backported from master: 2024-11-22 Tobias Burnus * gfortran.h (gfc_omp_namelist): Cleanup interop internal representation. * dump-parse-tree.cc (show_omp_namelist): Update for changed internal representation. * match.cc (gfc_free_omp_namelist): Likewise. * openmp.cc (gfc_match_omp_prefer_type, gfc_match_omp_init): Likewise; also handle some corner cases better and update for newer 6.0 changes related to 'fr'. (resolve_omp_clauses): Add type-check for interop variables. * trans-openmp.cc (gfc_trans_omp_clauses): Handle init, use and destroy clauses. (gfc_trans_openmp_interop): New. (gfc_trans_omp_directive): Call it. 2025-01-27 Paul-Antoine Arras Backported from master: 2025-01-13 Paul-Antoine Arras * openmp.cc (gfc_match_omp_declare_variant): Match comma after directive name and between clauses. Emit more useful diagnostics. 2025-01-27 Paul-Antoine Arras Backported from master: 2025-01-02 Paul-Antoine Arras * dump-parse-tree.cc (show_omp_clauses): Handle novariants and nocontext clauses. (show_omp_node): Handle EXEC_OMP_DISPATCH. (show_code_node): Likewise. * frontend-passes.cc (gfc_code_walker): Handle novariants and nocontext. * gfortran.h (enum gfc_statement): Add ST_OMP_DISPATCH. (symbol_attribute): Add omp_declare_variant_need_device_ptr. (gfc_omp_clauses): Add novariants and nocontext. (gfc_omp_declare_variant): Add need_device_ptr_arg_list. (enum gfc_exec_op): Add EXEC_OMP_DISPATCH. * match.h (gfc_match_omp_dispatch): Declare. * openmp.cc (gfc_free_omp_clauses): Free novariants and nocontext clauses. (gfc_free_omp_declare_variant_list): Free need_device_ptr_arg_list namelist. (enum omp_mask2): Add OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT. (gfc_match_omp_clauses): Handle OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT. (OMP_DISPATCH_CLAUSES): Define. (gfc_match_omp_dispatch): New function. (gfc_match_omp_declare_variant): Parse adjust_args. (resolve_omp_clauses): Handle adjust_args, novariants and nocontext. Adjust handling of OMP_LIST_IS_DEVICE_PTR. (icode_code_error_callback): Handle EXEC_OMP_DISPATCH. (omp_code_to_statement): Likewise. (resolve_omp_dispatch): New function. (gfc_resolve_omp_directive): Handle EXEC_OMP_DISPATCH. * parse.cc (decode_omp_directive): Match dispatch. (next_statement): Handle ST_OMP_DISPATCH. (gfc_ascii_statement): Likewise. (parse_omp_dispatch): New function. (parse_executable): Handle ST_OMP_DISPATCH. * resolve.cc (gfc_resolve_blocks): Handle EXEC_OMP_DISPATCH. * st.cc (gfc_free_statement): Likewise. * trans-decl.cc (create_function_arglist): Declare. (gfc_get_extern_function_decl): Call it. * trans-openmp.cc (gfc_trans_omp_clauses): Handle novariants and nocontext. (replace_omp_dispatch_call): New function. (gfc_trans_omp_dispatch): New function. (gfc_trans_omp_directive): Handle EXEC_OMP_DISPATCH. (gfc_trans_omp_declare_variant): Handle adjust_args. * trans.cc (trans_code): Handle EXEC_OMP_DISPATCH:. 2025-01-23 Paul-Antoine Arras Backported from master: 2024-11-20 Paul-Antoine Arras * types.def (BT_FN_PTR_CONST_PTR_INT): Declare. 2025-01-23 Tobias Burnus Backported from master: 2024-10-12 Tobias Burnus * array.cc (gfc_match_array_constructor): Only update the character length if the expression is of character type. * error.cc (gfc_get_location_with_offset): New; split off from ... (gfc_format_decoder): ... here; call it. * gfortran.h (gfc_get_location_with_offset): New prototype. (gfc_get_location): New inline function. * trans.cc (gfc_get_location): Remove function definition. * trans.h (gfc_get_location): Remove declaration. 2025-01-23 Tobias Burnus Backported from master: 2024-09-25 Tobias Burnus * parse.cc (decode_omp_directive): Set target-used bit of omp_requires_mask when encountering the declare_target or interop directive. 2025-01-23 Tobias Burnus Backported from master: 2024-09-13 Tobias Burnus PR fortran/116661 * gfortran.h (gfc_omp_namelist): Rename 'init' members for clarity. * match.cc (gfc_free_omp_namelist): Handle renaming. * dump-parse-tree.cc (show_omp_namelist): Update for new format and features. * openmp.cc (gfc_match_omp_prefer_type): Parse list to 'fr' and 'attr'; store 'fr' values as integer. (gfc_match_omp_init): Rename variable names. 2025-01-23 Tobias Burnus Backported from master: 2024-09-11 Tobias Burnus PR fortran/116661 * openmp.cc (gfc_match_omp_prefer_type): NULL init a gfc_expr variable and use right locus in gfc_error. 2025-01-23 Tobias Burnus Backported from master: 2024-09-06 Tobias Burnus * dump-parse-tree.cc (show_omp_namelist): Handle OMP_LIST_INIT. (show_omp_clauses): Handle OMP_LIST_{INIT,USE,DESTORY}; move 'nowait' from end-directive to the directive dump. (show_omp_node, show_code_node): Handle EXEC_OMP_INTEROP. * gfortran.h (enum gfc_statement): Add ST_OMP_INTEROP. (OMP_LIST_INIT, OMP_LIST_USE, OMP_LIST_DESTROY): Add. (enum gfc_exec_op): Add EXEC_OMP_INTEROP. (struct gfc_omp_namelist): Add interop items to union. (gfc_free_omp_namelist): Add boolean arg. * match.cc (gfc_free_omp_namelist): Update to free interop union members. * match.h (gfc_match_omp_interop): New. * openmp.cc (gfc_omp_directives): Uncomment 'interop' entry. (gfc_free_omp_clauses, gfc_match_omp_allocate, gfc_match_omp_flush, gfc_match_omp_clause_reduction): Update call. (enum omp_mask2): Add OMP_CLAUSE_{INIT,USE,DESTROY}. (OMP_INTEROP_CLAUSES): Use it. (gfc_match_omp_clauses): Match those clauses. (gfc_match_omp_prefer_type, gfc_match_omp_init, gfc_match_omp_interop): New. (resolve_omp_clauses): Handle interop clauses. (omp_code_to_statement): Add ST_OMP_INTEROP. (gfc_resolve_omp_directive): Add EXEC_OMP_INTEROP. * parse.cc (decode_omp_directive): Parse 'interop' directive. (next_statement, gfc_ascii_statement): Handle ST_OMP_INTEROP. * st.cc (gfc_free_statement): Likewise * resolve.cc (gfc_resolve_code): Handle EXEC_OMP_INTEROP. * trans.cc (trans_code): Likewise. * trans-openmp.cc (gfc_trans_omp_directive): Print 'sorry' for EXEC_OMP_INTEROP. 2024-07-29 Tobias Burnus Backported from master: 2024-07-29 Tobias Burnus PR fortran/115559 * trans-common.cc (build_common_decl): Add 'omp declare target' and 'omp declare target link' variables to offload_vars. * trans-decl.cc (add_attributes_to_decl): Likewise; update args and call decl_attributes. (get_proc_pointer_decl, gfc_get_extern_function_decl, build_function_decl): Update calls. (gfc_get_symbol_decl): Likewise; move after 'DECL_STATIC (t)=1' to avoid errors with symtab_node::get_create. 2024-07-03 Thomas Schwinge * class.cc (generate_callback_wrapper) [GCC_NVPTX_H]: Disable. 2024-05-15 Jakub Jelinek * openmp.cc (resolve_omp_clauses): Diagnose grainsize used together with num_tasks or nogroup used together with reduction. 2024-05-04 Sandra Loosemore * trans-openmp.cc (gfc_trans_omp_declare_variant): Adjust arguments to omp_context_selector_matches. (gfc_trans_omp_metadirective): Likewise. 2024-05-04 Sandra Loosemore * decl.cc (gfc_match_end): Handle metadirectives. * dump-parse-tree.cc (show_omp_node): Likewise. (show_code_node): Likewise. * gfortran.h (enum gfc_statement): Add ST_OMP_METADIRECTIVE. (struct gfc_omp_clauses): Rename target_first_st_is_teams field to target_first_st_is_teams_or_meta. (struct gfc_omp_variant): New. (struct gfc_st_label): Add omp_region field. (gfc_exec_op): Add EXEC_OMP_METADIRECTIVE. (struct gfc_code): Add omp_variants field. (gfc_free_omp_variants): Declare. (match_omp_directive): Declare. (is_omp_declarative_stmt): Declare. * io.cc (format_asterisk): Add initializer for new omp_region field. * match.h (gfc_match_omp_begin_metadirective): Declare. (gfc_match_omp_metadirective): Declare. * openmp.cc (gfc_match_omp_eos): Special case for matching an OpenMP context selector. (gfc_free_omp_variants): New. (gfc_match_omp_clauses): Remove context_selector parameter. (match_omp): Adjust call to gfc_match_omp_clauses. (gfc_match_omp_context_selector): Add metadirective_p parameter. Adjust error-checking logic and calls to gfc_match_omp_clauses. Set gfc_matching_omp_context_selector. (gfc_match_omp_context_selector_specification): Generalize to take a set selector list pointer as parameter, instead of a declare variant pointer. (gfc_match_omp_declare_variant): Adjust call to match above change. (match_omp_metadirective): New. (gfc_match_omp_begin_metadirective): New. (gfc_match_omp_metadirective): New. (resolve_omp_metadirective): New. (resolve_omp_target): Handle metadirectives. (gfc_resolve_omp_directive): Handle metadirectives. * parse.cc (gfc_matching_omp_context_selector): New. (gfc_in_metadirective_body): New. (gfc_omp_region_count): New. (decode_omp_directive): Handle "begin metadirective", "end metadirective", and "metadirective". (match_omp_directive): New. (case_omp_structured_block): New define. (case_omp_do): New define. (gfc_ascii_statement): Handle ST_OMP_BEGIN_METADIRECTIVE, ST_OMP_END_METADIRECTIVE, and ST_OMP_METADIRECTIVE. (accept_statement): Handle ST_OMP_BEGIN_METADIRECTIVE and ST_OMP_METADIRECTIVE. (gfc_omp_end_stmt): New. (parse_omp_do): Use gfc_omp_end_stmt. Special-case "omp end metadirective" to end the current construct. (parse_omp_structured_block): Likewise. Adjust setting of target_first_st_is_teams_or_meta flag. (parse_omp_metadirective_body): New. (parse_executable): Handle metadirectives. Use case_omp_structured_block and case_omp_do here. (gfc_parse_file): Initialize gfc_omp_region_count, gfc_in_metadirective_body, and gfc_matching_omp_context_selector. (is_omp_declarative_stmt): New. * parse.h (enum gfc_compile_state): Add metadirective constructs. (gfc_omp_end_stmt): Declare. (gfc_matching_omp_context_selector): Declare. (gfc_in_metadirective_body): Declare. (gfc_omp_region_count): Declare. * resolve.cc (gfc_resolve_code): Handle EXEC_OMP_METADIRECTIVE. * st.cc (gfc_free_statement): Handle EXEC_OMP_METADIRECTIVE. * symbol.cc (compare_st_labels): Compare omp_region, not just the value. (gfc_get_st_label): Likewise. Initialize the omp_region field when creating a new label. * trans-decl.cc (gfc_get_label_decl): Encode the omp_region in the label name. * trans-openmp.cc (gfc_trans_omp_directive): Handle EXEC_OMP_METADIRECTIVE. (gfc_trans_omp_set_selector): New, split from... (gfc_trans_omp_declare_variant): ...here. (gfc_trans_omp_metadirective): New. * trans-stmt.h (gfc_trans_omp_metadirective): Declare. * trans.cc (trans_code): Handle EXEC_OMP_METADIRECTIVE. 2024-05-04 Sandra Loosemore * trans-openmp.cc (gfc_trans_omp_declare_variant): Update calls to omp_check_context_selector and omp_context_selector_matches. * types.def (BT_FN_BOOL_INT_CONST_PTR_CONST_PTR_CONST_PTR): New. 2023-10-30 Tobias Burnus * trans-openmp.cc (gfc_trans_omp_clauses): Avoid gfc_evaluate_now for allocator with indirect ref for better diagnostic. 2023-07-14 Julian Brown * trans-openmp.cc (gfc_trans_omp_arrayshape_type): Reverse dimension ordering for created array type. 2023-07-03 Julian Brown * trans-openmp.cc (gfc_omp_deep_map_kind_p): Handle GOMP_MAP_{TO,FROM}_GRID, GOMP_MAP_GRID_{DIM,STRIDE}. (gfc_trans_omp_arrayshape_type, gfc_omp_calculate_gcd, gfc_desc_to_omp_noncontig_array, gfc_omp_contiguous_update_p): New functions. (gfc_trans_omp_clauses): Handle noncontiguous to/from clauses for OMP "target update" directives. 2023-08-10 Julian Brown * openmp.cc (gfc_match_motion_var_list): Add parsing for mapper modifier. (gfc_match_omp_clauses): Adjust error handling for changes to gfc_match_motion_var_list. * trans-openmp.cc (gfc_trans_omp_clauses): Use correct ref for update operations. (gfc_trans_omp_target_update): Instantiate mappers. 2023-08-10 Julian Brown * gfortran.h (gfc_omp_namelist_udm): Add MAPPER_ID field to store the mapper name to use for lookup during resolution. * match.cc (gfc_free_omp_namelist): Handle OMP_LIST_TO and OMP_LIST_FROM when freeing mapper references. * module.cc (load_omp_udms, write_omp_udm): Handle MAPPER_ID field. * openmp.cc (gfc_match_omp_clauses): Handle explicitly-specified 'default' name. Don't do mapper lookup here, but record mapper name if the user specifies one. (resolve_omp_clauses): Do mapper lookup here instead. Report error for missing named mapper. 2023-08-10 Julian Brown * gfortran.h (gfc_omp_clauses): Add NS field. * openmp.cc (verify_omp_clauses_symbol_dups, omp_verify_map_motion_clauses): New functions, broken out of... (resolve_omp_clauses): Here. Record namespace containing clauses. Call above functions. (resolve_omp_mapper_clauses): New function, using helper functions broken out above. (gfc_resolve_omp_directive): Add NS parameter to resolve_omp_clauses calls. (gfc_omp_instantiate_mappers): Call resolve_omp_mapper_clauses if we instantiate any mappers. 2023-08-10 Julian Brown * gfortran.h (toc_directive): Move here. (gfc_omp_instantiate_mappers, gfc_get_location): Add prototypes. * openmp.cc (omp_split_map_op, omp_join_map_op, omp_map_decayed_kind, omp_basic_map_kind_name, gfc_subst_replace, gfc_subst_prepend_ref, gfc_subst_in_expr_1, gfc_subst_in_expr, gfc_subst_mapper_var): Move here. (gfc_omp_instantiate_mapper, gfc_omp_instantiate_mappers): Move here and rename. * trans-openmp.cc (toc_directive, omp_split_map_op, omp_join_map_op, omp_map_decayed_kind, gfc_subst_replace, gfc_subst_prepend_ref, gfc_subst_in_expr_1, gfc_subst_in_expr, gfc_subst_mapper_var, gfc_trans_omp_instantiate_mapper, gfc_trans_omp_instantiate_mappers): Remove from here. (gfc_trans_omp_target, gfc_trans_omp_target_data, gfc_trans_omp_target_enter_data, gfc_trans_omp_target_exit_data): Rename calls to gfc_omp_instantiate_mappers. 2023-07-06 Julian Brown * trans-openmp.cc (omp_split_map_op, omp_join_map_op, omp_map_decayed_kind): New functions. (gfc_trans_omp_instantiate_mapper): Add CD parameter. Implement map kind decay. (gfc_trans_omp_instantiate_mappers): Add CD parameter. Pass to above function. (gfc_trans_omp_target_data): Instantiate mappers for 'omp target data'. (gfc_trans_omp_target_enter_data): Instantiate mappers for 'omp target enter data'. (gfc_trans_omp_target_exit_data): Instantiate mappers for 'omp target exit data'. 2023-06-30 Julian Brown * dump-parse-tree.cc (show_attr): Show omp_udm_artificial_var flag. (show_omp_namelist): Support OMP_MAP_POINTER_ONLY and OMP_MAP_UNSET. * f95-lang.cc (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE, LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define language hooks. * gfortran.h (gfc_statement): Add ST_OMP_DECLARE_MAPPER. (symbol_attribute): Add omp_udm_artificial_var attribute. (gfc_omp_map_op): Add OMP_MAP_POINTER_ONLY and OMP_MAP_UNSET. (gfc_omp_namelist): Add udm pointer to u2 union. (gfc_omp_udm): New struct. (gfc_omp_namelist_udm): New struct. (gfc_symtree): Add omp_udm pointer. (gfc_namespace): Add omp_udm_root symtree. Add omp_udm_ns flag. (gfc_free_omp_namelist): Update prototype. (gfc_free_omp_udm, gfc_omp_udm_find, gfc_find_omp_udm, gfc_resolve_omp_udms): Add prototypes. * match.cc (gfc_free_omp_namelist): Change FREE_NS and FREE_ALIGN parameters to LIST number, to handle freeing user-defined mapper namelists safely. * match.h (gfc_match_omp_declare_mapper): Add prototype. * module.cc (ab_attribute): Add AB_OMP_DECLARE_MAPPER_VAR. (attr_bits): Add OMP_DECLARE_MAPPER_VAR. (mio_symbol_attribute): Read/write AB_OMP_DECLARE_MAPPER_VAR attribute. Set referenced attr on read. (omp_map_clause_ops, omp_map_cardinality): New arrays. (load_omp_udms, check_omp_declare_mappers): New functions. (read_module): Load and check OMP declare mappers. (write_omp_udm, write_omp_udms): New functions. (write_module): Write OMP declare mappers. * openmp.cc (gfc_free_omp_clauses, gfc_match_omp_variable_list, gfc_match_omp_to_link, gfc_match_omp_depend_sink, gfc_match_omp_clause_reduction): Update calls to gfc_free_omp_namelist. (gfc_free_omp_udm, gfc_find_omp_udm, gfc_omp_udm_find, gfc_match_omp_declare_mapper): New functions. (gfc_match_omp_clauses): Add DEFAULT_MAP_OP parameter. Update calls to gfc_free_omp_namelist. Add declare mapper support. (resolve_omp_clauses): Add declare mapper support. Update calls to gfc_free_omp_namelist. (gfc_resolve_omp_udm, gfc_resolve_omp_udms): New functions. * parse.cc (decode_omp_directive): Add declare mapper support. (case_omp_decl): Add ST_OMP_DECLARE_MAPPER case. (gfc_ascii_statement): Add ST_OMP_DECLARE_MAPPER case. * resolve.cc (resolve_types): Call gfc_resolve_omp_udms. * st.cc (gfc_free_statement): Update call to gfc_free_omp_namelist. * symbol.cc (free_omp_udm_tree): New function. (gfc_free_namespace): Call above. * trans-decl.cc (omp_declare_mapper_ns): New global. (gfc_finish_var_decl, gfc_generate_function_code): Support declare mappers. (gfc_trans_deferred_vars): Ignore artificial declare-mapper vars. * trans-openmp.cc (tree-iterator.h): Include. (toc_directive): New enum. (gfc_trans_omp_array_section): Change OP and OPENMP parameters to toc_directive CD ('clause directive'). (gfc_omp_finish_mapper_clauses, gfc_omp_extract_mapper_directive, gfc_omp_map_array_section): New functions. (omp_clause_directive): New enum. (gfc_trans_omp_clauses): Remove DECLARE_SIMD and OPENACC parameters. Replace with toc_directive CD, defaulting to TOC_OPENMP. Add declare mapper support and OMP_MAP_POINTER_ONLY support. (gfc_trans_omp_construct, gfc_trans_oacc_executable_directive, gfc_trans_oacc_combined_directive): Update calls to gfc_trans_omp_clauses. (gfc_subst_replace, gfc_subst_prepend_ref): New variables. (gfc_subst_in_expr_1, gfc_subst_in_expr, gfc_subst_mapper_var, gfc_trans_omp_instantiate_mapper, gfc_trans_omp_instantiate_mappers, gfc_record_mapper_bindings_code_fn, gfc_record_mapper_bindings_expr_fn, gfc_find_nested_mappers, gfc_record_mapper_bindings): New functions. (gfc_typespec * hash traits): New template. (omp_declare_mapper_ns): Extern declaration. (gfc_trans_omp_target): Call gfc_trans_omp_instantiate_mappers and gfc_record_mapper_bindings. Update calls to gfc_trans_omp_clauses. (gfc_trans_omp_declare_simd, gfc_trans_omp_declare_variant): Update calls to gfc_trans_omp_clauses. (gfc_trans_omp_mapper_name, gfc_trans_omp_declare_mapper, gfc_trans_omp_declare_mappers): New functions. * trans-stmt.h (gfc_trans_omp_declare_mappers): Add prototype. * trans.h (gfc_omp_finish_mapper_clauses, gfc_omp_extract_mapper_directive, gfc_omp_map_array_section): Add prototypes. 2023-06-30 Julian Brown * parse.cc (tree.h, fold-const.h, tree-hash-traits.h): Add includes (for additions to omp-general.h). 2023-06-19 Julian Brown * trans-openmp.cc (gfc_omp_finish_clause): Treat implicitly-mapped assumed-size arrays as zero-sized for OpenACC, rather than an error. 2023-06-19 Julian Brown * trans-openmp.cc (gfc_omp_finish_clause): Handle "declare create" for scalar allocatable variables. (gfc_trans_omp_clauses): Don't include allocatable vars in synthetic "acc data" region created for "declare create" variables. Mark such variables with the "oacc declare create" attribute instead. Don't create ALWAYS_POINTER mapping for target-to-host updates of declare create variables. (gfc_trans_oacc_declare): Handle empty clause list. 2024-06-05 Jakub Jelinek Frederik Harwath Sandra Loosemore * gfortran.h (enum gfc_statement): Add ST_OMP_UNROLL, ST_OMP_END_UNROLL, ST_OMP_TILE and ST_OMP_END_TILE. (struct gfc_omp_clauses): Add sizes_list, partial, full and erroneous members. (enum gfc_exec_op): Add EXEC_OMP_UNROLL and EXEC_OMP_TILE. (gfc_expr_list_len): Declare. * match.h (gfc_match_omp_tile, gfc_match_omp_unroll): Declare. * openmp.cc (gfc_get_location): Declare. (gfc_free_omp_clauses): Free sizes_list. (match_oacc_expr_list): Rename to ... (match_omp_oacc_expr_list): ... this. Add is_omp argument and change diagnostic wording if it is true. (enum omp_mask2): Add OMP_CLAUSE_{FULL,PARTIAL,SIZES}. (gfc_match_omp_clauses): Parse full, partial and sizes clauses. (gfc_match_oacc_wait): Use match_omp_oacc_expr_list instead of match_oacc_expr_list. (OMP_UNROLL_CLAUSES, OMP_TILE_CLAUSES): Define. (gfc_match_omp_tile, gfc_match_omp_unroll): New functions. (resolve_omp_clauses): Diagnose full vs. partial clause conflict. Resolve sizes clause arguments. (find_nested_loop_in_chain): Use switch instead of series of ifs. Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL. (gfc_resolve_omp_do_blocks): Set omp_current_do_collapse to list length of sizes_list if present. (gfc_resolve_do_iterator): Return for EXEC_OMP_TILE or EXEC_OMP_UNROLL. (restructure_intervening_code): Remove spurious ()s around & operands. (is_outer_iteration_variable): Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL. (check_nested_loop_in_chain): Likewise. (expr_is_invariant): Likewise. (resolve_omp_do): Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL. Diagnose tile without sizes clause. Use sizes_list length for count if non-NULL. Set code->ext.omp_clauses->erroneous on loops where we've reported diagnostics. Sorry for mixing non-rectangular loops with generated loops. (omp_code_to_statement): Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL. (gfc_resolve_omp_directive): Likewise. * parse.cc (decode_omp_directive): Parse end tile, end unroll, tile and unroll. Move nothing entry alphabetically. (case_exec_markers): Add ST_OMP_TILE and ST_OMP_UNROLL. (gfc_ascii_statement): Handle ST_OMP_END_TILE, ST_OMP_END_UNROLL, ST_OMP_TILE and ST_OMP_UNROLL. (parse_omp_do): Add nested argument. Handle ST_OMP_TILE and ST_OMP_UNROLL. (parse_omp_structured_block): Adjust parse_omp_do caller. (parse_executable): Likewise. Handle ST_OMP_TILE and ST_OMP_UNROLL. * resolve.cc (gfc_resolve_blocks): Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL. (gfc_resolve_code): Likewise. * st.cc (gfc_free_statement): Likewise. * trans.cc (trans_code): Likewise. * trans-openmp.cc (gfc_trans_omp_clauses): Handle full, partial and sizes clauses. Use tree_cons + nreverse instead of temporary vector and build_tree_list_vec for tile_list handling. (gfc_expr_list_len): New function. (gfc_trans_omp_do): Rename tile to oacc_tile. Handle sizes clause. Don't assert code->op is EXEC_DO. Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL. (gfc_trans_omp_directive): Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL. * dump-parse-tree.cc (show_omp_clauses): Dump full, partial and sizes clauses. (show_omp_node): Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL. (show_code_node): Likewise. 2023-03-23 Tobias Burnus * trans-openmp.cc (gfc_has_alloc_comps): Add 'bool shallow_alloc_only=false' arg. (gfc_omp_replace_alloc_by_to_mapping): New, call it. (gfc_omp_deep_map_kind_p): Return 'true' also for '(present,)alloc'. (gfc_omp_deep_mapping_item, gfc_omp_deep_mapping_do): On map entering, replace shallowly 'alloc'/'from' by '(from)to' mapping if there are allocatable components. 2023-03-23 Tobias Burnus * class.cc (generate_callback_wrapper): Add attr.class_ok check. * resolve.cc (resolve_fl_derived): Likewise. 2022-11-02 Tobias Burnus * trans-openmp.cc (gfc_trans_omp_clauses): Ensure DT struct-comp with array descriptor and 'alloc:' have the descriptor mapped with 'to:'. 2022-11-02 Tobias Burnus * openmp.cc (resolve_omp_clauses): Apply to OpenMP target update. 2023-11-19 Tobias Burnus Chung-Lin Tang * trans-array.cc (gfc_conv_array_initializer): Set PURPOSE when building constructor for get_initialized_tmp_var. * trans-openmp.cc (gfc_trans_omp_clauses): Handle uses_allocators. * types.def (BT_FN_VOID_PTRMODE, BT_FN_PTRMODE_PTRMODE_INT_PTR): Add. 2022-05-12 Tobias Burnus * trans-array.cc (gfc_scalar_elemental_arg_saved_as_reference): Return true for attr.proc_pointer expressions. 2022-04-27 Tobias Burnus * resolve.cc (gfc_resolve_finalizers): Remove gfc_resolve_finalizers calls, use gfc_is_finalizable. (resolve_fl_derived): Resolve derived-type components first. 2022-04-25 Tobias Burnus * resolve.cc (gfc_resolve_finalizers): Also resolve allocatable comps. 2022-03-01 Tobias Burnus * class.cc (finalization_scalarizer): Mark syms as artificial. (generate_callback_wrapper): New. (gfc_find_derived_vtab): Call it, add _callback comp. * f95-lang.cc (LANG_HOOKS_OMP_DEEP_MAPPING, LANG_HOOKS_OMP_DEEP_MAPPING_P, LANG_HOOKS_OMP_DEEP_MAPPING_CNT): Redeinfe * gfortran.h (gfc_import_iso_c_binding_module, GFC_CLASS_CALLBACK_DEFAULT_FLAG, GFC_CLASS_CALLBACK_VTABLE_FLAG, GFC_CLASS_CB_ALLOCATABLE, GFC_CLASS_CB_POINTER, GFC_CLASS_CB_PROC_POINTER, GFC_CLASS_CB_VTABLE, GFC_CLASS_CB_VPTR): New. * match.cc (select_type_set_tmp): Propagate allocatable property. * module.cc (MOD_VERSION): Bump due to vtab change. (import_iso_c_binding_module): New import_all arg. (gfc_import_iso_c_binding_module): New. (gfc_use_module): Update call. * openmp.cc (resolve_omp_clauses): Accept DT with alloc comps. * resolve.cc (gfc_resolve_formal_arglist, gfc_resolve_intrinsic, resolve_fl_procedure, resolve_types): Permit some violations for internal code. * trans-array.cc (gfc_conv_descriptor_stride_get, gfc_tree_array_size, gfc_full_array_size): Update for GFC_TYPE_ARRAY_AKIND change. (gfc_conv_expr_descriptor): Likewise; permit calling with tree code. * trans-expr.cc (VTABLE_CALLBACK_FIELD): Add. (VTAB_GET_FIELD_GEN): Use it. (VTABLE_DEALLOCATE_FIELD): Undef at the end. (gfc_conv_expr_reference): Fixes; avoid unneccessary temp var. * trans-intrinsic.cc (gfc_conv_intrinsic_sizeof, gfc_conv_associated): Fix class and comp-ref handling. (conv_isocbinding_function): Remove buggy code. * trans-openmp.ccc (gfc_has_alloc_comps): Add ptr_ok arg. (gfc_omp_private_outer_ref, gfc_walk_alloc_comps, gfc_omp_clause_default_ctor, gfc_omp_clause_copy_ctor, gfc_omp_clause_assign_op, gfc_omp_clause_dtor, (gfc_omp_finish_clause): Update call. (GFC_MAP_TOKEN_DATA, GFC_MAP_TOKEN_SIZES, GFC_MAP_TOKEN_KINDS, GFC_MAP_TOKEN_DATA_OFFSET, GFC_MAP_TOKEN_OFFSET, GFC_MAP_TOKEN_FLAGS, GFC_MAP_TOKEN_DETACH): Define. (gfc_omp_get_token_data, gfc_omp_get_token_sizes, gfc_omp_get_token_kinds, gfc_omp_get_token_offset_data, gfc_omp_get_token_offset, gfc_omp_get_token_flags, gfc_omp_get_token_detach, gfc_omp_get_map_token_type, gfc_omp_get_cb_type, gfc_omp_gen_deep_map_fn, gfc_omp_deep_mapping_map, gfc_omp_deep_mapping_item, gfc_omp_deep_mapping_comps, gfc_omp_gen_simple_loop, gfc_omp_get_array_size, gfc_omp_elmental_loop, gfc_omp_deep_map_kind_p, gfc_omp_deep_mapping_int_p, gfc_omp_deep_mapping_p, gfc_omp_deep_mapping_do), gfc_omp_deep_mapping_cnt, gfc_omp_deep_mapping): New. (gfc_trans_omp_array_section): Save clause decl to survive gimplifying. (gfc_trans_omp_clauses): Likewise; fixes. * trans-types.cc (gfc_build_array_type, gfc_get_derived_type, gfc_get_array_descr_info): Update array kind to distinguish different assumed-rank arrays. * trans.h (gfc_class_vtab_callback_get, gfc_omp_deep_mapping_p, gfc_omp_deep_mapping_cnt, gfc_omp_deep_mapping): New prototypes. (enum gfc_array_kind): Additional GFC_ARRAY_ASSUMED_RANK_* entries. 2020-02-19 Julian Brown * trans-openmp.ccc (gfc_omp_check_optional_argument): Handle non-decl case. 2018-10-04 Cesar Philippidis Julian Brown * gfortran.h (enum gfc_omp_map_op): Add OMP_MAP_DECLARE_ALLOCATE, OMP_MAP_DECLARE_DEALLOCATE. (gfc_omp_clauses): Add update_allocatable. * trans-array.c (gfc_array_allocate): Call gfc_trans_oacc_declare_allocate for decls that have oacc_declare_create attribute set. * trans-decl.c (find_module_oacc_declare_clauses): Relax oacc_declare_create to OMP_MAP_ALLOC, and oacc_declare_copyin to OMP_MAP_TO, in order to match OpenACC 2.5 semantics. * trans-openmp.c (gfc_trans_omp_clauses): Use GOMP_MAP_ALWAYS_POINTER (for update directive) or GOMP_MAP_FIRSTPRIVATE_POINTER (otherwise) for allocatable scalar decls. Handle OMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE} clauses. (gfc_trans_oacc_executable_directive): Use GOMP_MAP_ALWAYS_POINTER for allocatable scalar data clauses inside acc update directives. (gfc_trans_oacc_declare_allocate): New function. * trans-stmt.c (gfc_trans_allocate): Call gfc_trans_oacc_declare_allocate for decls with oacc_declare_create attribute set. (gfc_trans_deallocate): Likewise. * trans.h (gfc_trans_oacc_declare_allocate): Declare. 2018-12-13 Cesar Philippidis Nathan Sidwell Julian Brown * openmp.cc (oacc_is_parallel): New. (resolve_oacc_loop_blocks): Emit an error on orphan OpenACC gang reductions. * trans-openmp.ccc (gfc_omp_clause_copy_ctor): Permit reductions. 2018-06-29 Cesar Philippidis James Norris * openmp.cc (resolve_positive_int_expr): Promote the warning to an error. 2020-04-19 Chung-Lin Tang PR other/76739 * f95-lang.cc (DEF_FUNCTION_TYPE_VAR_5): New symbol. * types.def (BT_FN_VOID_INT_SIZE_PTR_PTR_PTR_VAR): New type.