Commit Graph

730 Commits

Author SHA1 Message Date
GCC Administrator
adaeecb1f5 Daily bump. 2026-02-06 00:16:39 +00:00
Matthieu Longo
7722c043f0 libiberty: add helper to swap doubly-linked list wrappers
This patch introduces a new helper to swap the contents of two
doubly-linked list wrappers. The new *_swap_lists operation exchanges
the first, last, and size fields, allowing two lists to be swapped
efficiently without iterating over their elements.

This helper is intended for cases where the ownership of a list must be
exchanged but swapping wrapper pointers is not possible. For simple
references to lists, when wrappers are dynamically allocated, swapping
the wrapper pointers themselves is sufficient and remains the preferred
approach.

This change adds the necessary declaration and definition macros to
doubly-linked-list.h and integrates them into the set of mutative
list operations.

The testsuite is updated accordingly to cover the new functionality.

include/ChangeLog:

	* doubly-linked-list.h
	(LINKED_LIST_SWAP_LISTS): Add new helper.
	(LINKED_LIST_DECL_SWAP_LISTS): Likewise.
	(LINKED_LIST_DEFN_SWAP_LISTS): Likewise.
	(LWRAPPERTYPE##_swap_lists): Likewise.

libiberty/ChangeLog:

	* testsuite/test-doubly-linked-list.c: Update.
2026-02-05 15:35:03 +00:00
GCC Administrator
d77d64766a Daily bump. 2026-02-04 00:16:33 +00:00
Andrew Stubbs
a53c5c42c6 libgomp, amdgcn, nvptx: Improve omp_target_is_accessible [PR121813]
This patch extends omp_target_is_accessible to check the actual device status
for the memory region, on amdgcn and nvptx devices (rather than just checking
if shared memory is enabled).

In both cases, we check the status of each 4k region within the given memory
range (assuming 4k pages should be safe for all the currently supported hosts)
and returns true if all of the pages report accessible.

The testcases have been modified to check that allocations marked accessible
actually are accessible (inaccessibility can't be checked without invoking
memory faults), and to understand that some parts of an array can be accessible
but other parts not (I have observed this intermittently for the stack memory
on amdgcn using the Fortran testcase, which can have the allocation span pages).

There's also new testcases for the various other memory modes, and for managed
memory.

include/ChangeLog:

	* cuda/cuda.h (CUpointer_attribute): New enum.
	(cuPointerGetAttribute): New prototype.

libgomp/ChangeLog:

	PR libgomp/121813
	PR libgomp/113213
	* libgomp-plugin.h (GOMP_OFFLOAD_is_accessible_ptr): New prototype.
	* libgomp.h
	(struct gomp_device_descr): Add GOMP_OFFLOAD_is_accessible_ptr.
	* libgomp.texi: Update omp_target_is_accessible docs.
	* plugin/cuda-lib.def (cuPointerGetAttribute): New entry.
	* plugin/plugin-gcn.c (struct hsa_runtime_fn_info): Add
	hsa_amd_svm_attributes_get_fn and hsa_amd_pointer_info_fn.
	(init_hsa_runtime_functions): Add hsa_amd_svm_attributes_get and
	hsa_amd_pointer_info.
	(enum accessible): New enum type.
	(host_memory_is_accessible): New function.
	(device_memory_is_accessible): New function.
	(GOMP_OFFLOAD_is_accessible_ptr): New function.
	* plugin/plugin-nvptx.c (GOMP_OFFLOAD_is_accessible_ptr): Likewise.
	* target.c (omp_target_is_accessible): Call is_accessible_ptr_func.
	(gomp_load_plugin_for_device): Add is_accessible_ptr.
	* testsuite/libgomp.c-c++-common/target-is-accessible-1.c: Rework
	to match more details of the GPU implementation.
	* testsuite/libgomp.fortran/target-is-accessible-1.f90: Likewise.
	* testsuite/libgomp.c-c++-common/target-is-accessible-2.c: New test.
	* testsuite/libgomp.c-c++-common/target-is-accessible-3.c: New test.
	* testsuite/libgomp.c-c++-common/target-is-accessible-4.c: New test.
	* testsuite/libgomp.c-c++-common/target-is-accessible-5.c: New test.
2026-02-03 13:17:38 +00:00
Jakub Jelinek
254a858ae7 Update copyright years. 2026-01-02 09:56:11 +01:00
GCC Administrator
bcbb536551 Daily bump. 2025-12-13 00:16:34 +00:00
mengqinggang
5c821cbae4 LoongArch: C and .h files for LA32
gcc/ChangeLog:

	* config/loongarch/loongarch-opts.cc (loongarch_target_option_override):
	Delete opts->x_flag_pcc_struct_return and enable mstrict-align by
	default on LA32.
	* config/loongarch/loongarch.cc (loongarch_for_each_saved_reg): Save reg
	depend on float abi.
	(loongarch_explicit_relocs_p): Disable explicit relocs on LA32.
	(loongarch_valid_offset_p): Disable const_imm16_operand with 4 byte aligned.
	(loongarch_valid_lo_sum_p): Allow lo_sum to be used with DF in ilp32d.
	(loongarch_valid_index_p): Disable ADDRESS_REG_REG on LA32.
	(loongarch_legitimize_address): Disable mem_shadd_or_shadd_rtx_p on LA32.
	(loongarch_output_move_index):  Assert TARGET_64BIT for ldx/stx.
	(loongarch_output_move): Disable ldptr/stptr if offset is 0.
	(loongarch_output_equal_conditional_branch): Disable beqz/bnez on LA32R.
	(loongarch_trampoline_init): Change pcaddi to pcaddu12i.
	(loongarch_get_separate_components): Disable ldptr/stptr on LA32.
	(loongarch_c_mode_for_floating_type): Use TFmode for long double
	regardless of target bitness.
	(loongarch_bitint_type_info): Disable BitInt on LA32.
	(loongarch_call_tls_get_addr): Use call30 on LA32.
	(loongarch_split_move): Add split for DI, DF, TF.
	* config/loongarch/loongarch.h (LA_LONG_DOUBLE_TYPE_SIZE): Set
	LONG_DOUBLE_TYPE_SIZE to 128 regardless of target bitness.
	(MAX_FIXED_MODE_SIZE): Set to 64 on LA32.
	(DEFAULT_PCC_STRUCT_RETURN): New.
	(STACK_BOUNDARY): Set to 128 on LA64 and LA32.
	(LARCH_STACK_ALIGN): Set to 16 on LA64 and LA32.
	(TRAMPOLINE_SIZE): Set to same value on LA64 and LA32.

include/ChangeLog:

	* longlong.h (count_leading_zeros): Delete because LA32R no clz.
	(count_trailing_zeros): Delete because LA32R no ctz.
	(COUNT_LEADING_ZEROS_0): Delete.

Co-authored-by: Jiajie Chen <c@jia.je>
Reviewed-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Lulu Cheng <chenglulu@loongson.cn>
2025-12-12 15:56:46 +08:00
GCC Administrator
68de3c4b89 Daily bump. 2025-12-02 09:47:45 +00:00
Andrew Stubbs
723b18ce3d libgomp, amdgcn: Implement Managed Memory
This patch implements "managed" memory for AMD GCN GPUs in OpenMP.  It
builds on the support added to the NVPTX libgomp for CUDA Managed Memory, a
week or two ago.

These features were first posted here a few years ago, as part of a larger
Unified Shared Memory patch series, and then in a slightly changed version just
over a year ago.  Hopefully this time the controversial bits have been removed.

Since we do not use HIP we cannot use hipMallocManaged, so this patch attempts
to replicate the same effect by setting the appropriate attributes.  This works
on more devices than support proper USM, but still I cannot be sure that the
settings are correct for every device out there (I have tested on gfx900,
gfx906, gfx908, gfx90a, and gfx1100).

The HSA header file update uses the most recent files relicensed for us by AMD,
at the time of the first patch posting.  Those files have certainly moved on in
the upstream sources, but I did not ask to get those relicensed.

include/ChangeLog:

	* hsa.h: Import newer version.
	* hsa_ext_amd.h: Likewise.
	* hsa_ext_image.h: Likewise.

libgomp/ChangeLog:

	* Makefile.in: Regenerate.
	* libgomp-plugin.h (gomp_simple_alloc_init_context): New prototype.
	(gomp_simple_alloc_register_memory): New prototype.
	(gomp_simple_alloc): New prototype.
	(gomp_simple_free): New prototype.
	(gomp_simple_realloc): New prototype.
	* libgomp.h (gomp_simple_alloc_init_context): Move to libgomp-plugin.h.
	(gomp_simple_alloc_register_memory): Likewise.
	(gomp_simple_alloc): Likewise.
	(gomp_simple_free): Likewise.
	(gomp_simple_realloc): Likewise.
	* libgomp.texi: Update AMD managed memory description.
	* plugin/Makefrag.am (libgomp_plugin_gcn_la_SOURCES): Add
	simple-allocator.c and plugin/mutex.c.
	* plugin/plugin-gcn.c: Include sys/mman.h and unistd.h.
	(struct hsa_runtime_fn_info): Add hsa_amd_svm_attributes_set_fn.
	(dump_hsa_system_info): Add HSA_AMD_SYSTEM_INFO_SVM_SUPPORTED and
	HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT to the GCN_DEBUG output.
	(init_hsa_runtime_functions): Add hsa_amd_svm_attributes_set.
	(isa_matches_agent): Add a new error message for the case where the
	ISA doesn't match but the name does.
	(managed_ctx): New variable.
	(managed_heap_create): New function.
	(GOMP_OFFLOAD_managed_alloc): Likewise.
	(GOMP_OFFLOAD_managed_free): Likewise.
	* simple-allocator.c (gomp_fatal): New macro.
	* testsuite/lib/libgomp.exp (check_effective_target_omp_managedmem):
	Add amdgcn support checker.
	(check_effective_target_offload_target_amdgcn_with_xnack): New.
	* testsuite/libgomp.c-c++-common/requires-4.c: Ignore xnack warning.
	* testsuite/libgomp.c-c++-common/requires-4a.c: Ignore xnack warning.
	* testsuite/libgomp.c-c++-common/requires-5.c: Ignore xnack warning.
	* testsuite/libgomp.c++/alloc-managed-1.C: Add -mxnack=on, if needed.
	* testsuite/libgomp.c/alloc-managed-1.c: Likewise.
	* testsuite/libgomp.c/alloc-managed-2.c: Likewise.
	* testsuite/libgomp.c/alloc-managed-3.c: Likewise.
	* testsuite/libgomp.c/alloc-managed-4.c: Likewise.
	* testsuite/libgomp.fortran/alloc-managed-1.f90: Likewise.
	* plugin/mutex.c: New file.
2025-12-01 12:03:35 +00:00
GCC Administrator
3b30d09ac7 Daily bump. 2025-12-01 00:16:36 +00:00
Jose E. Marchesi
0d787df6f2 a68: DWARF language codes
This commit makes GCC aware of the DWARF numbers recently allocated
for Algol 68.

For DWARF 5, DW_LANG_Algol68 = 0x44.
For DWARF 6, DW_LNAME_Algol68 = 0x2e
    with versioning schema YYYY, starting with 1973 for the original
    Revised language. The language extensions we are working on will
    be encoded in subsequent versions, 2025 etc.

See https://dwarfstd.org/issues/250304.1.html for more information.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>

gcc/ChangeLog

	* dwarf2out.cc: Set DW_LANG_Algol68 an DW_LNAME_Algol68.

include/ChangeLog

	* dwarf2.h (DW_LANG_Algol68): Define.
	(DW_LNAME_Algol68): Likewise.
2025-11-30 01:52:25 +01:00
GCC Administrator
890dff609d Daily bump. 2025-11-14 00:20:34 +00:00
Andrew Stubbs
62174ec27b openmp, nvptx: ompx_gnu_managed_mem_alloc
This adds support for using Cuda Managed Memory with omp_alloc.  AMD support
will be added in a future patch.

There is one new predefined allocator, "ompx_gnu_managed_mem_alloc", plus a
corresponding memory space, which can be used to allocate memory in the
"managed" space.

The nvptx plugin is modified to make the necessary Cuda calls, via two new
(optional) plugin interfaces.

gcc/fortran/ChangeLog:

	* openmp.cc (is_predefined_allocator): Use GOMP_OMP_PREDEF_ALLOC_MAX
	and GOMP_OMPX_PREDEF_ALLOC_MIN/MAX instead of hardcoded values in the
	comment.

include/ChangeLog:

	* cuda/cuda.h (cuMemAllocManaged): Add declaration and related
	CU_MEM_ATTACH_GLOBAL flag.
	* gomp-constants.h (GOMP_OMPX_PREDEF_ALLOC_MAX): Update to 201.
	(GOMP_OMP_PREDEF_MEMSPACE_MAX): New constant.
	(GOMP_OMPX_PREDEF_MEMSPACE_MIN): New constant.
	(GOMP_OMPX_PREDEF_MEMSPACE_MAX): New constant.

libgomp/ChangeLog:

	* allocator.c (ompx_gnu_max_predefined_alloc): Update to
	ompx_gnu_managed_mem_alloc.
	(_Static_assert): Fix assertion messages for allocators and add
	new assertions for memspace constants.
	(omp_max_predefined_mem_space): New define.
	(ompx_gnu_min_predefined_mem_space): New define.
	(ompx_gnu_max_predefined_mem_space): New define.
	(MEMSPACE_ALLOC): Add check for non-standard memspaces.
	(MEMSPACE_CALLOC): Likewise.
	(MEMSPACE_REALLOC): Likewise.
	(MEMSPACE_VALIDATE): Likewise.
	(predefined_ompx_gnu_alloc_mapping): Add ompx_gnu_managed_mem_space.
	(omp_init_allocator): Add ompx_gnu_managed_mem_space validation.
	* config/gcn/allocator.c (gcn_memspace_alloc): Add check for
	non-standard memspaces.
	(gcn_memspace_calloc): Likewise.
	(gcn_memspace_realloc): Likewise.
	(gcn_memspace_validate): Update to validate standard vs non-standard
	memspaces.
	* config/linux/allocator.c (linux_memspace_alloc): Add managed
	memory space handling.
	(linux_memspace_calloc): Likewise.
	(linux_memspace_free): Likewise.
	(linux_memspace_realloc): Likewise (returns NULL for fallback).
	* config/nvptx/allocator.c (nvptx_memspace_alloc): Add check for
	non-standard memspaces.
	(nvptx_memspace_calloc): Likewise.
	(nvptx_memspace_realloc): Likewise.
	(nvptx_memspace_validate): Update to validate standard vs non-standard
	memspaces.
	* env.c (parse_allocator): Add ompx_gnu_managed_mem_alloc,
	ompx_gnu_managed_mem_space, and some static asserts so I don't forget
	them again.
	* libgomp-plugin.h (GOMP_OFFLOAD_managed_alloc): New declaration.
	(GOMP_OFFLOAD_managed_free): New declaration.
	* libgomp.h (gomp_managed_alloc): New declaration.
	(gomp_managed_free): New declaration.
	(struct gomp_device_descr): Add managed_alloc_func and
	managed_free_func fields.
	* libgomp.texi: Document ompx_gnu_managed_mem_alloc and
	ompx_gnu_managed_mem_space, add C++ template documentation, and
	describe NVPTX and AMD support.
	* omp.h.in: Add ompx_gnu_managed_mem_space and
	ompx_gnu_managed_mem_alloc enumerators, and gnu_managed_mem C++
	allocator template.
	* omp_lib.f90.in: Add Fortran bindings for new allocator and
	memory space.
	* omp_lib.h.in: Likewise.
	* plugin/cuda-lib.def: Add cuMemAllocManaged.
	* plugin/plugin-nvptx.c (nvptx_alloc): Add managed parameter to
	support cuMemAllocManaged.
	(GOMP_OFFLOAD_alloc): Move contents to ...
	(cleanup_and_alloc): ... this new function, and add managed support.
	(GOMP_OFFLOAD_managed_alloc): New function.
	(GOMP_OFFLOAD_managed_free): New function.
	* target.c (gomp_managed_alloc): New function.
	(gomp_managed_free): New function.
	(gomp_load_plugin_for_device): Load optional managed_alloc
	and managed_free plugin APIs.
	* testsuite/lib/libgomp.exp: Add check_effective_target_omp_managedmem.
	* testsuite/libgomp.c++/alloc-managed-1.C: New test.
	* testsuite/libgomp.c/alloc-managed-1.c: New test.
	* testsuite/libgomp.c/alloc-managed-2.c: New test.
	* testsuite/libgomp.c/alloc-managed-3.c: New test.
	* testsuite/libgomp.c/alloc-managed-4.c: New test.
	* testsuite/libgomp.fortran/alloc-managed-1.f90: New test.

Co-authored-by: Kwok Cheung Yeung <kcyeung@baylibre.com>
Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
2025-11-13 14:16:09 +00:00
GCC Administrator
03fed2a80b Daily bump. 2025-10-17 00:18:48 +00:00
David Faust
822a139e7d dwarf: add wiki link for DWARF GNU_annotation extensions
include/

	* dwarf2.def (DW_TAG_GNU_annotation): Add link to wiki page
	documenting the extension.
	(DW_AT_GNU_annotation): Likewise.
2025-10-16 11:08:30 -07:00
GCC Administrator
ddd6dff0ba Daily bump. 2025-10-11 00:21:09 +00:00
Tobias Burnus
d2ad7e9083 libgomp: Add is_integrated_apu function to plugin/plugin-{gcn,nvptx}.c
The added function is currently '#if 0' but is planned to be used to enable
self mapping automatically. Prerequisite for auto self maps is still mapping
'declare target' variables (if any, in libgomp) or converting all
'declare target' variables to 'declare target link' in the compiler
(as required for 'omp requires self_maps').

include/ChangeLog:

	* hsa_ext_amd.h (enum hsa_amd_agent_info_s): Add
	HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES.
	(enum): Add HSA_AMD_MEMORY_PROPERTY_AGENT_IS_APU.

libgomp/ChangeLog:

	* plugin/plugin-gcn.c (is_integrated_apu): New; currently '#if 0'.
	* plugin/plugin-nvptx.c (is_integrated_apu): Likewise.
2025-10-10 09:48:37 +02:00
GCC Administrator
ea7fa6bf48 Daily bump. 2025-10-10 00:21:51 +00:00
David Faust
43dcea48b8 btf: generate and output DECL_TAG and TYPE_TAG records
Support the btf_decl_tag and btf_type_tag attributes in BTF by creating
and emitting BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records,
respectively, for them.

Some care is required when -gprune-btf is in effect to avoid emitting
decl or type tags for declarations or types which have been pruned and
will not be emitted in BTF.

gcc/
	* btfout.cc (get_btf_kind): Handle DECL_TAG and TYPE_TAG kinds.
	(btf_calc_num_vbytes): Likewise.
	(btf_asm_type): Likewise.
	(output_asm_btf_vlen_bytes): Likewise.
	(output_btf_tags): New.
	(btf_output): Call it here.
	(btf_add_used_type): Replace with simple wrapper around...
	(btf_add_used_type_1): ...the implementation.  Handle
	BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG.
	(btf_add_vars): Update btf_add_used_type call.
	(btf_assign_tag_ids): New.
	(btf_mark_type_used): Update btf_add_used_type call.
	(btf_collect_pruned_types): Likewise.  Handle type and decl tags.
	(btf_finish): Call btf_assign_tag_ids.

gcc/testsuite/
	* gcc.dg/debug/btf/btf-decl-tag-1.c: New test.
	* gcc.dg/debug/btf/btf-decl-tag-2.c: New test.
	* gcc.dg/debug/btf/btf-decl-tag-3.c: New test.
	* gcc.dg/debug/btf/btf-decl-tag-4.c: New test.
	* gcc.dg/debug/btf/btf-type-tag-1.c: New test.
	* gcc.dg/debug/btf/btf-type-tag-2.c: New test.
	* gcc.dg/debug/btf/btf-type-tag-3.c: New test.
	* gcc.dg/debug/btf/btf-type-tag-4.c: New test.
	* gcc.dg/debug/btf/btf-type-tag-c2x-1.c: New test.

include/
	* btf.h (BTF_KIND_DECL_TAG, BTF_KIND_TYPE_TAG) New defines.
	(struct btf_decl_tag): New.
2025-10-09 14:13:23 -07:00
David Faust
9c862a593b ctf: translate annotation DIEs to internal ctf
Translate DW_TAG_GNU_annotation DIEs created for C attributes
btf_decl_tag and btf_type_tag into an in-memory representation in the
CTF/BTF container.  They will be output in BTF as BTF_KIND_DECL_TAG and
BTF_KIND_TYPE_TAG records.

The new CTF kinds used to represent these annotations, CTF_K_DECL_TAG
and CTF_K_TYPE_TAG, are expected to be formalized in the next version of
the CTF specification.  For now they only exist in memory as a
translation step to BTF, and are not emitted when generating CTF
information.

gcc/
	* ctfc.cc (ctf_dtu_d_union_selector): Handle CTF_K_DECL_TAG and
	CTF_K_TYPE_TAG.
	(ctf_add_type_tag, ctf_add_decl_tag): New.
	(ctf_add_variable): Return the new ctf_dvdef_ref rather than zero.
	(new_ctf_container): Initialize new members.
	(ctfc_delete_container): Deallocate new members.
	* ctfc.h (ctf_dvdef, ctf_dvdef_t, ctf_dvdef_ref): Move forward
	declarations earlier in file.
	(ctf_decl_tag_t): New typedef.
	(ctf_dtdef): Add ctf_decl_tag_t member to dtd_u union.
	(ctf_dtu_d_union_enum): Add new CTF_DTU_D_TAG enumerator.
	(ctf_container): Add ctfc_tags vector and ctfc_type_tags_map hash_map
	members.
	(ctf_add_type_tag, ctf_add_decl_tag): New function protos.
	(ctf_add_variable): Change prototype return type to ctf_dvdef_ref.
	* dwarf2ctf.cc (gen_ctf_type_tags, gen_ctf_decl_tags)
	(gen_ctf_decl_tags_for_var): New static functions.
	(gen_ctf_pointer_type): Handle type tags.
	(gen_ctf_sou_type): Handle decl tags.
	(gen_ctf_function_type): Likewise.
	(gen_ctf_variable): Likewise.
	(gen_ctf_function): Likewise.
	(gen_ctf_type): Handle TAG_GNU_annotation DIEs.

gcc/testsuite/
	* gcc.dg/debug/ctf/ctf-decl-tag-1.c: New test.
	* gcc.dg/debug/ctf/ctf-type-tag-1.c: New test.

include/
	* ctf.h (CTF_K_DECL_TAG, CTF_K_TYPE_TAG): New defines.
2025-10-09 14:13:23 -07:00
David Faust
ac7027f180 dwarf: create annotation DIEs for btf tags
The btf_decl_tag and btf_type_tag attributes provide a means to annotate
declarations and types respectively with arbitrary user provided
strings.  These strings are recorded in debug information for
post-compilation uses, and despite the name they are meant to be
recorded in DWARF as well as BTF.  New DWARF extensions
DW_TAG_GNU_annotation and DW_AT_GNU_annotation are used to represent
these user annotations in DWARF.

This patch introduces the new DWARF extension DIE and attribute, and
generates them as necessary to represent user annotations from
btf_decl_tag and btf_type_tag.

The format of the new DIE is as follows:

    DW_TAG_GNU_annotation
        DW_AT_name: "btf_decl_tag" or "btf_type_tag"
        DW_AT_const_value: <arbitrary user-supplied string>
        DW_AT_GNU_annotation: <reference to another TAG_GNU_annotation DIE>

DW_AT_GNU_annotation is a new attribute extension used to refer to these
new annotation DIEs.  If non-null in any given declaration or type DIE,
it is a reference to a DW_TAG_GNU_annotation DIE holding an annotation
for that declaration or type.  In addition, the DW_TAG_GNU_annotation
DIEs may also have a non-null DW_AT_GNU_annotation, referring to another
annotation DIE.  This allows chains of annotation DIEs to be formed,
such as in the case where a single declaration has multiple instances of
btf_decl_tag with different string annotations.

gcc/
	* dwarf2out.cc (struct annotation_node, struct annotation_node_hasher)
	(btf_tag_htab): New ancillary structures and hash table.
	(annotation_node_hasher::hash, annotation_node_hasher::equal): New.
	(hash_btf_tag, gen_btf_tag_dies, maybe_gen_btf_type_tag_dies)
	(maybe_gen_btf_decl_tag_dies): New functions.
	(modified_type_die): Add new argument to pass type attributes.
	Handle btf_type_tag, and update recursive calls.
	(base_type_for_mode): Add new arg for modified_type_die call.
	(add_type_attribute): Likewise.
	(gen_array_type_die): Call maybe_gen_btf_type_tag_dies for the type.
	(gen_formal_parameter_die): Call maybe_gen_btf_decl_tag_dies for the
	parameter.
	(override_type_for_decl_p): Add new arg for modified_type_die call.
	(force_type_die): Likewise.
	(gen_tagged_type_die): Call maybe_gen_btf_type_tag_dies for the type.
	(gen_decl_die): Call maybe_gen_btf_decl_tag_dies for the decl.
	(dwarf2out_finish): Empty btf_tag_htab.
	(dwarf2out_cc_finalize): Delete btf_tag_htab hash table.

include/
	* dwarf2.def (DW_TAG_GNU_annotation): New DWARF extension.
	(DW_AT_GNU_annotation): Likewise.

gcc/testsuite/
	* gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-1.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-2.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-3.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-1.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-2.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-3.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-4.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-5.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-6.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-7.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-8.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-9.c: New test.
	* gcc.dg/debug/dwarf2/dwarf-btf-type-tag-10.c: New test.
2025-10-09 14:13:23 -07:00
GCC Administrator
b42c5ee445 Daily bump. 2025-08-17 00:19:17 +00:00
Nathaniel Shead
7921bb4afc c++: Implement P2115R0 linkage changes for unnamed unscoped enums [PR120503]
We currently list P2115R0 as implemented, but only the modules changes
had been done.  This patch implements the linkage changes so that
unnamed unscoped enums will use the name of the first enumerator for
linkage purposes.

This is (strictly speaking) a breaking change, as code that previously
relied on unnamed enumerations being internal linkage may have overloads
using those types become exposed and clash with other functions in a
different TU that have been similarly exposed.  As such this feature is
only implemented for C++20.

No ABI flag warning is provided, partly because C++20 is still an
experimental standard, but also because any affected functions could not
have been part of an ABI until this change anyway.

A number of testcases that are testing for behaviour of no-linkage types
are adjusted to use an enumeration with no values, so that the pre-C++20
and post-C++20 behaviour is equivalently tested.

In terms of implementation, I had originally considered adjusting the
DECL_NAME of the enum, as with 'name_unnamed_type', but this ended up
being more complicated as it had unwanted interactions with the existing
modules streaming and with name lookup and diagnostic messages.  This
patch instead uses a new function to derive this case.

The standard says that ([dcl.enum] p11) such an enum "...is denoted, for
linkage purposes, by its underlying type and its first enumerator", so
we need to add a new mangling production as well to handle this.

	PR c++/120503
	PR c++/120824

gcc/cp/ChangeLog:

	* cp-tree.h (TYPE_UNNAMED_P): Adjust for enums with enumerators
	for linkage purposes.
	(enum_with_enumerator_for_linkage_p): Declare.
	* decl.cc (name_unnamed_type): Adjust assertions to handle enums
	with enumerators for linkage purposes.
	(grokdeclarator): Use a typedef name for enums with enumerators
	for linkage purposes.
	(enum_with_enumerator_for_linkage_p): New function.
	(finish_enum_value_list): Reset type linkage for enums with
	enumerators for linkage purposes.
	* mangle.cc (write_unnamed_enum_name): New function.
	(write_unqualified_name): Handle enums with enumerators for
	linkage purposes.
	* tree.cc (decl_linkage): Fixup unnamed enums.

gcc/testsuite/ChangeLog:

	* g++.dg/abi/mangle32.C: Remove enumerator list.
	* g++.dg/cpp0x/linkage2.C: Likewise.
	* g++.dg/ext/vector26.C: Likewise.
	* g++.dg/other/anon3.C: Likewise.
	* g++.dg/abi/mangle83.C: New test.
	* g++.dg/modules/enum-15_a.C: New test.
	* g++.dg/modules/enum-15_b.C: New test.

include/ChangeLog:

	* demangle.h (enum demangle_component_type): Add enumeration
	DEMANGLE_COMPONENT_UNNAMED_ENUM.

libiberty/ChangeLog:

	* cp-demangle.c (d_unnamed_enum): New function.
	(d_unqualified_name): Call it.
	(cplus_demangle_type): Handle unscoped unnamed types
	(Ue, Ul, etc.)
	(d_count_templates_scopes): Handle unnamed enums.
	(d_find_pack): Likewise.
	(d_print_comp_inner): Print unnamed enums.
	* testsuite/demangle-expected: Add tests.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2025-08-17 10:14:14 +10:00
GCC Administrator
285422c70e Daily bump. 2025-07-10 00:20:18 +00:00
Matthieu Longo
0fd98b6f9f libiberty: add routines to handle type-sensitive doubly linked lists
Those methods's implementation is relying on duck-typing at compile
time.
The structure corresponding to the node of a doubly linked list needs
to define attributes 'prev' and 'next' which are pointers on the type
of a node.
The structure wrapping the nodes and others metadata (first, last, size)
needs to define pointers 'first', and 'last' of the node's type, and
an integer type for 'size'.

Mutative methods can be bundled together and be declarable once via a
same macro, or can be declared separately. The merge sort is bundled
separately.
There are 3 types of macros:
1. for the declaration of prototypes: to use in a header file for a
   public declaration, or as a forward declaration in the source file
   for private declaration.
2. for the declaration of the implementation: to use always in a
   source file.
3. for the invocation of the functions.

The methods can be declared either public or private via the second
argument of the declaration macros.

List of currently implemented methods:
- LINKED_LIST_*:
    - APPEND: insert a node at the end of the list.
    - PREPEND: insert a node at the beginning of the list.
    - INSERT_BEFORE: insert a node before the given node.
    - POP_FRONT: remove the first node of the list.
    - POP_BACK: remove the last node of the list.
    - REMOVE: remove the given node from the list.
    - SWAP: swap the two given nodes in the list.
- LINKED_LIST_MERGE_SORT: a merge sort implementation.

include/ChangeLog:

	* doubly-linked-list.h: New file.

libiberty/ChangeLog:

	* Makefile.in: Add new header.
	* testsuite/Makefile.in: Add new test.
	* testsuite/test-doubly-linked-list.c: New test.
2025-07-09 16:15:55 +01:00
GCC Administrator
c8124997a5 Daily bump. 2025-06-21 00:18:50 +00:00
Sosutha Sethuramapandian
e08ef05e4d [PATCH] RISC-V: Use builtin clz/ctz when count_leading_zeros and count_trailing_zeros is used
longlong.h for RISCV should define count_leading_zeros and
count_trailing_zeros and COUNT_LEADING_ZEROS_0 when ZBB is enabled.

The following patch patch fixes the bug reported in,
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110181

The divdi3 on riscv32 with zbb extension generates __clz_tab
instead of genearating  __builtin_clzll/__builtin_clz which is
not efficient since lookup table is emitted.

Updating longlong.h to use this __builtin_clzll/__builtin_clz
generates optimized code for the instruction.

	PR target/110181

include/ChangeLog

	* longlong.h  [__riscv] (count_leading_zeros): Define.
	[__riscv] (count_trailing_zeros): Likewise.
	[__riscv] (COUNT_LEADING_ZEROS_0): Likewise.
2025-06-19 20:56:09 -06:00
GCC Administrator
13699eb988 Daily bump. 2025-06-03 00:18:06 +00:00
Tobias Burnus
4e47e2f833 libgomp: Add OpenMP's omp_target_memset/omp_target_memset_async
PR libgomp/120444

include/ChangeLog:

	* cuda/cuda.h (cuMemsetD8, cuMemsetD8Async): Declare.

libgomp/ChangeLog:

	* libgomp-plugin.h (GOMP_OFFLOAD_memset): Declare.
	* libgomp.h (struct gomp_device_descr): Add memset_func.
	* libgomp.map (GOMP_6.0.1): Add omp_target_memset{,_async}.
	* libgomp.texi (Device Memory Routines): Document them.
	* omp.h.in (omp_target_memset, omp_target_memset_async): Declare.
	* omp_lib.f90.in (omp_target_memset, omp_target_memset_async):
	Add interfaces.
	* omp_lib.h.in (omp_target_memset, omp_target_memset_async): Likewise.
	* plugin/cuda-lib.def: Add cuMemsetD8.
	* plugin/plugin-gcn.c (struct hsa_runtime_fn_info): Add
	hsa_amd_memory_fill_fn.
	(init_hsa_runtime_functions): DLSYM_OPT_FN load it.
	(GOMP_OFFLOAD_memset): New.
	* plugin/plugin-nvptx.c (GOMP_OFFLOAD_memset): New.
	* target.c (omp_target_memset_int, omp_target_memset,
	omp_target_memset_async_helper, omp_target_memset_async): New.
	(gomp_load_plugin_for_device): Add DLSYM (memset).
	* testsuite/libgomp.c-c++-common/omp_target_memset.c: New test.
	* testsuite/libgomp.c-c++-common/omp_target_memset-2.c: New test.
	* testsuite/libgomp.c-c++-common/omp_target_memset-3.c: New test.
	* testsuite/libgomp.fortran/omp_target_memset.f90: New test.
	* testsuite/libgomp.fortran/omp_target_memset-2.f90: New test.
2025-06-02 17:43:57 +02:00
GCC Administrator
c7df2b7d43 Daily bump. 2025-05-31 00:19:06 +00:00
Julian Brown
48973e8783 OpenMP: C++ "declare mapper" support
This patch adds support for OpenMP 5.0 "declare mapper" functionality
for C++.  I've merged it to og13 based on the last version
posted upstream, with some minor changes due to the newly-added
'present' map modifier support.  There's also a fix to splay-tree
traversal in gimplify.cc:omp_instantiate_implicit_mappers, and this patch
omits the rearrangement of gimplify.cc:gimplify_{scan,adjust}_omp_clauses
that I separated out into its own patch and applied (to og13) already.

gcc/c-family/
	* c-common.h (c_omp_region_type): Add C_ORT_DECLARE_MAPPER and
	C_ORT_OMP_DECLARE_MAPPER codes.
	(omp_mapper_list): Add forward declaration.
	(c_omp_find_nested_mappers, c_omp_instantiate_mappers): Add prototypes.
	* c-omp.cc (c_omp_find_nested_mappers): New function.
	(remap_mapper_decl_info): New struct.
	(remap_mapper_decl_1, omp_instantiate_mapper,
	c_omp_instantiate_mappers): New functions.

gcc/cp/
	* constexpr.cc (reduced_constant_expression_p): Add OMP_DECLARE_MAPPER
	case.
	(cxx_eval_constant_expression, potential_constant_expression_1):
	Likewise.
	* cp-gimplify.cc (cxx_omp_finish_mapper_clauses): New function.
	* cp-objcp-common.h (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES,
	LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE,
	LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define langhooks.
	* cp-tree.h (lang_decl_base): Add omp_declare_mapper_p field.  Recount
	spare bits comment.
	(DECL_OMP_DECLARE_MAPPER_P): New macro.
	(omp_mapper_id): Add prototype.
	(cp_check_omp_declare_mapper): Add prototype.
	(omp_instantiate_mappers): Add prototype.
	(cxx_omp_finish_mapper_clauses): Add prototype.
	(cxx_omp_mapper_lookup): Add prototype.
	(cxx_omp_extract_mapper_directive): Add prototype.
	(cxx_omp_map_array_section): Add prototype.
	* decl.cc (check_initializer): Add OpenMP declare mapper support.
	(cp_finish_decl): Set DECL_INITIAL for OpenMP declare mapper var decls
	as appropriate.
	* decl2.cc (mark_used): Instantiate OpenMP "declare mapper" magic var
	decls.
	* error.cc (dump_omp_declare_mapper): New function.
	(dump_simple_decl): Use above.
	* parser.cc (cp_parser_omp_clause_map): Add KIND parameter.  Support
	"mapper" modifier.
	(cp_parser_omp_all_clauses): Add KIND argument to
	cp_parser_omp_clause_map call.
	(cp_parser_omp_target): Call omp_instantiate_mappers before
	finish_omp_clauses.
	(cp_parser_omp_declare_mapper): New function.
	(cp_parser_omp_declare): Add "declare mapper" support.
	* pt.cc (tsubst_decl): Adjust name of "declare mapper" magic var decls
	once we know their type.
	(tsubst_omp_clauses): Call omp_instantiate_mappers before
	finish_omp_clauses, for target regions.
	(tsubst_expr): Support OMP_DECLARE_MAPPER nodes.
	(instantiate_decl): Instantiate initialiser (i.e definition) for OpenMP
	declare mappers.
	* semantics.cc (gimplify.h): Include.
	(omp_mapper_id, omp_mapper_lookup, omp_extract_mapper_directive,
	cxx_omp_map_array_section, cp_check_omp_declare_mapper): New functions.
	(finish_omp_clauses): Delete GOMP_MAP_PUSH_MAPPER_NAME and
	GOMP_MAP_POP_MAPPER_NAME artificial clauses.
	(omp_target_walk_data): Add MAPPERS field.
	(finish_omp_target_clauses_r): Scan for uses of struct/union/class type
	variables.
	(finish_omp_target_clauses): Create artificial mapper binding clauses
	for used structs/unions/classes in offload region.

gcc/fortran/
	* parse.cc (tree.h, fold-const.h, tree-hash-traits.h): Add includes
	(for additions to omp-general.h).

gcc/
	* gimplify.cc (gimplify_omp_ctx): Add IMPLICIT_MAPPERS field.
	(new_omp_context): Initialise IMPLICIT_MAPPERS hash map.
	(delete_omp_context): Delete IMPLICIT_MAPPERS hash map.
	(instantiate_mapper_info): New structs.
	(remap_mapper_decl_1, omp_mapper_copy_decl, omp_instantiate_mapper,
	omp_instantiate_implicit_mappers): New functions.
	(gimplify_scan_omp_clauses): Handle MAPPER_BINDING clauses.
	(gimplify_adjust_omp_clauses): Instantiate implicit declared mappers.
	(gimplify_omp_declare_mapper): New function.
	(gimplify_expr): Call above function.
	* langhooks-def.h (lhd_omp_mapper_lookup,
	lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): Add
	prototypes.
	(LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES,
	LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE,
	LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define macros.
	(LANG_HOOK_DECLS): Add above macros.
	* langhooks.cc (lhd_omp_mapper_lookup,
	lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): New
	dummy functions.
	* langhooks.h (lang_hooks_for_decls): Add OMP_FINISH_MAPPER_CLAUSES,
	OMP_MAPPER_LOOKUP, OMP_EXTRACT_MAPPER_DIRECTIVE, OMP_MAP_ARRAY_SECTION
	hooks.
	* omp-general.h (omp_name_type<T>): Add templatized struct, hash type
	traits (for omp_name_type<tree> specialization).
	(omp_mapper_list<T>): Add struct.
	* tree-core.h (omp_clause_code): Add OMP_CLAUSE__MAPPER_BINDING_.
	* tree-pretty-print.cc (dump_omp_clause): Support GOMP_MAP_UNSET,
	GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping
	clauses.  Support OMP_CLAUSE__MAPPER_BINDING_ and OMP_DECLARE_MAPPER.
	* tree.cc (omp_clause_num_ops, omp_clause_code_name): Add
	OMP_CLAUSE__MAPPER_BINDING_.
	* tree.def (OMP_DECLARE_MAPPER): New tree code.
	* tree.h (OMP_DECLARE_MAPPER_ID, OMP_DECLARE_MAPPER_DECL,
	OMP_DECLARE_MAPPER_CLAUSES): New defines.
	(OMP_CLAUSE__MAPPER_BINDING__ID, OMP_CLAUSE__MAPPER_BINDING__DECL,
	OMP_CLAUSE__MAPPER_BINDING__MAPPER): New defines.

include/
	* gomp-constants.h (gomp_map_kind): Add GOMP_MAP_UNSET,
	GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping
	clause types.

gcc/testsuite/
	* c-c++-common/gomp/map-6.c: Update error scan output.
	* c-c++-common/gomp/declare-mapper-3.c: New test (only enabled for C++
	for now).
	* c-c++-common/gomp/declare-mapper-4.c: Likewise.
	* c-c++-common/gomp/declare-mapper-5.c: Likewise.
	* c-c++-common/gomp/declare-mapper-6.c: Likewise.
	* c-c++-common/gomp/declare-mapper-7.c: Likewise.
	* c-c++-common/gomp/declare-mapper-8.c: Likewise.
	* c-c++-common/gomp/declare-mapper-9.c: Likewise.
	* c-c++-common/gomp/declare-mapper-10.c: Likewise.
	* c-c++-common/gomp/declare-mapper-12.c: Likewise.
	* g++.dg/gomp/declare-mapper-1.C: New test.
	* g++.dg/gomp/declare-mapper-2.C: New test.
	* g++.dg/gomp/declare-mapper-3.C: New test.

libgomp/
	* testsuite/libgomp.c++/declare-mapper-1.C: New test.
	* testsuite/libgomp.c++/declare-mapper-2.C: New test.
	* testsuite/libgomp.c++/declare-mapper-3.C: New test.
	* testsuite/libgomp.c++/declare-mapper-4.C: New test.
	* testsuite/libgomp.c++/declare-mapper-5.C: New test.
	* testsuite/libgomp.c++/declare-mapper-6.C: New test.
	* testsuite/libgomp.c++/declare-mapper-7.C: New test.
	* testsuite/libgomp.c++/declare-mapper-8.C: New test.
	* testsuite/libgomp.c-c++-common/declare-mapper-9.c: New test (only
	enabled for C++ for now).
	* testsuite/libgomp.c-c++-common/declare-mapper-10.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-11.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-12.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-13.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-14.c: Likewise.

Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
2025-05-30 09:00:37 +02:00
GCC Administrator
19ed7c9262 Daily bump. 2025-05-15 00:19:47 +00:00
Andreas Schwab
4a49450b94 libiberty: remove duplicated declaration of mkstemps
* libiberty.h (mkstemps): Remove duplicate.
2025-05-14 15:58:33 +02:00
GCC Administrator
cc63163f0a Daily bump. 2025-03-30 00:16:46 +00:00
Iain Sandoe
9018336252 libiberty, gcc: Add memrchr to libiberty and use it [PR119283].
This adds an implementation of memrchr to libiberty and arranges
to configure gcc to use it, if the host does not have it.

	PR cobol/119283

gcc/ChangeLog:

	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Check for host memrchr.

include/ChangeLog:

	* libiberty.h (memrchr): New.

libiberty/ChangeLog:

	* Makefile.in: Add memrchr build rules.
	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Check for memrchr.
	* functions.texi: Document memrchr.
	* memrchr.c: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-03-29 13:53:22 +00:00
GCC Administrator
7a6bbab6ae Daily bump. 2025-03-22 09:25:44 +00:00
Paul-Antoine Arras
99e2906ae2 OpenMP: 'interop' construct - add ME support + target-independent libgomp
This patch partially enables use of the OpenMP interop construct by adding
middle end support, mostly in the omplower pass, and in the target-independent
part of the libgomp runtime. It follows up on previous patches for C, C++ and
Fortran front ends support. The full interop feature requires another patch to
enable foreign runtime support in libgomp plugins.

gcc/ChangeLog:

	* builtin-types.def
	(BT_FN_VOID_INT_INT_PTR_PTR_PTR_INT_PTR_INT_PTR_UINT_PTR): New.
	* gimple-low.cc (lower_stmt): Handle GIMPLE_OMP_INTEROP.
	* gimple-pretty-print.cc (dump_gimple_omp_interop): New function.
	(pp_gimple_stmt_1): Handle GIMPLE_OMP_INTEROP.
	* gimple.cc (gimple_build_omp_interop): New function.
	(gimple_copy): Handle GIMPLE_OMP_INTEROP.
	* gimple.def (GIMPLE_OMP_INTEROP): Define.
	* gimple.h (gimple_build_omp_interop): Declare.
	(gimple_omp_interop_clauses): New function.
	(gimple_omp_interop_clauses_ptr): Likewise.
	(gimple_omp_interop_set_clauses): Likewise.
	(gimple_return_set_retval): Handle GIMPLE_OMP_INTEROP.
	* gimplify.cc (gimplify_scan_omp_clauses): Handle OMP_CLAUSE_INIT,
	OMP_CLAUSE_USE and OMP_CLAUSE_DESTROY.
	(gimplify_omp_interop): New function.
	(gimplify_expr): Replace sorry with call to gimplify_omp_interop.
	* omp-builtins.def (BUILT_IN_GOMP_INTEROP): Define.
	* omp-low.cc (scan_sharing_clauses): Handle OMP_CLAUSE_INIT,
	OMP_CLAUSE_USE and OMP_CLAUSE_DESTROY.
	(scan_omp_1_stmt): Handle GIMPLE_OMP_INTEROP.
	(lower_omp_interop_action_clauses): New function.
	(lower_omp_interop): Likewise.
	(lower_omp_1): Handle GIMPLE_OMP_INTEROP.

gcc/c/ChangeLog:

	* c-parser.cc (c_parser_omp_clause_destroy): Make addressable.
	(c_parser_omp_clause_init): Make addressable.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_omp_clause_init): Make addressable.

gcc/fortran/ChangeLog:

	* 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.

include/ChangeLog:

	* gomp-constants.h (GOMP_DEVICE_DEFAULT_OMP_61, GOMP_INTEROP_TARGET,
	GOMP_INTEROP_TARGETSYNC, GOMP_INTEROP_FLAG_NOWAIT): Define.

libgomp/ChangeLog:

	* icv-device.c (omp_set_default_device): Check
	GOMP_DEVICE_DEFAULT_OMP_61.
	* libgomp-plugin.h (struct interop_obj_t): New.
	(enum gomp_interop_flag): New.
	(GOMP_OFFLOAD_interop): Declare.
	(GOMP_OFFLOAD_get_interop_int): Declare.
	(GOMP_OFFLOAD_get_interop_ptr): Declare.
	(GOMP_OFFLOAD_get_interop_str): Declare.
	(GOMP_OFFLOAD_get_interop_type_desc): Declare.
	* libgomp.h (_LIBGOMP_OMP_LOCK_DEFINED): Define.
	(struct gomp_device_descr): Add interop_func, get_interop_int_func,
	get_interop_ptr_func, get_interop_str_func, get_interop_type_desc_func.
	* libgomp.map: Add GOMP_interop.
	* libgomp_g.h (GOMP_interop): Declare.
	* target.c (resolve_device): Handle GOMP_DEVICE_DEFAULT_OMP_61.
	(omp_get_interop_int): Replace stub with actual implementation.
	(omp_get_interop_ptr): Likewise.
	(omp_get_interop_str): Likewise.
	(omp_get_interop_type_desc): Likewise.
	(struct interop_data_t): Define.
	(gomp_interop_internal): New function.
	(GOMP_interop): Likewise.
	(gomp_load_plugin_for_device): Load symbols for get_interop_int,
	get_interop_ptr, get_interop_str and get_interop_type_desc.
	* testsuite/libgomp.c-c++-common/interop-1.c: New test.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/interop-1.c: Remove dg-prune-output "sorry".
	* c-c++-common/gomp/interop-2.c: Likewise.
	* c-c++-common/gomp/interop-3.c: Likewise.
	* c-c++-common/gomp/interop-4.c: Remove dg-message "not supported".
	* g++.dg/gomp/interop-5.C: Likewise.
	* gfortran.dg/gomp/interop-4.f90: Likewise.
	* c-c++-common/gomp/interop-5.c: New test.
	* gfortran.dg/gomp/interop-5.f90: New test.

Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
2025-03-21 19:24:16 +01:00
GCC Administrator
a03e863975 Daily bump. 2025-03-19 00:17:56 +00:00
Jose E. Marchesi
31dd621796 libiberty: add ldirname function
This patch adds a function ldirname to libiberty.  It is implemented
in terms of lbasename.  Basically, given a given pathname, the dirname
part is what is not the basename minus the last directory separator
separating the dirname with the basename.

include/ChangeLog

	* libiberty.h (ldirname): New function declaration.
	(dos_ldirname): Likewise.
	(unix_ldirname): Likewise.

libiberty/ChangeLog

	* ldirname.c: New file.
	* Makefile.in (CFILES): Add ldirname.c.
	(REQUIRED_OFILES): Add ldirname.$(objext).
	(./ldirname.$(objext)): New rule.
	* makefile.vms (OBJS): Add ldirname.obj.
	* configure.com (FILES): Add ldirname.
2025-03-18 11:19:48 +01:00
GCC Administrator
1fb2146baa Daily bump. 2025-02-12 00:17:11 +00:00
Roger Sayle
0f8fd6b336 Synchronize include/dwarf2.def with binutils
The contents of include/dwarf2.def have diverged between the gcc and
the binutils repositories.  Currently, it's impossible to build a combined
tree, as GCC won't build with the binutils version of dwarf2.def and binutils
won't build with the gcc version.  This patch realigns this file by copying
the defintion of DW_CFA_AARCH64_negate_ra_state_with_pc from binutils,
restoring the ability to build a combined source tree.

2025-02-11  Roger Sayle  <roger@nextmovesoftware.com>

include/ChangeLog
	* dwarf2.def (DW_CFA_AARCH64_negate_ra_state_with_pc): Define.
2025-02-11 12:21:43 +00:00
GCC Administrator
5f61fb4407 Daily bump. 2025-01-09 00:18:34 +00:00
Jakub Jelinek
ec99905f7b dwarf2out: Emit DWARF 6 DW_AT_language_{name,version}
DWARF has voted in recently https://dwarfstd.org/issues/241209.1.html ,
which is basically just a guarantee that the DWARF 6 draft
DW_AT_language_{name,version} attribute codes and content of
https://dwarfstd.org/languages-v6.html can be used as an extension
in DWARF 5 and won't be changed.

So, this patch is an alternative to the
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/669671.html
patch, which had the major problem that it required changing all the
DWARF consumers to be able to debug C17 or later or C++17 or later
sources.
This patch uses still DWARF 5 DW_LANG_C11 or DW_LANG_C_plus_plus_14,
the latest code in DWARF 5 proper, so all DWARF 5 capable consumers
should be able to deal with that, but additionally emits the
DWARF 6 attributes so that newer DWARF consumers can see it isn't
just C++14 but say C++23 or C11 but C23.  Consumers which don't know
those DWARF 6 attributes would just ignore them.  This is like any other
-gno-strict-dwarf extension, except that normally we emit say DWARF 5
codes where possible only after DWARF 5 is released, while in this case
there is a guarantee it can be used before DWARF 6 is released.

2025-01-08  Jakub Jelinek  <jakub@redhat.com>

include/
	* dwarf2.h (enum dwarf_source_language): Fix comment pasto.
	(enum dwarf_source_language_name): New type.
	* dwarf2.def (DW_AT_language_name, DW_AT_language_version): New
	DWARF 6 codes.
gcc/
	* dwarf2out.cc (break_out_comdat_types): Copy over
	DW_AT_language_{name,version} if present.
	(output_skeleton_debug_sections): Remove also
	DW_AT_language_{name,version}.
	(gen_compile_unit_die): For C17, C23, C2Y, C++17, C++20, C++23
	and C++26 emit for -gdwarf-5 -gno-strict-dwarf also
	DW_AT_language_{name,version} attributes.
gcc/testsuite/
	* g++.dg/debug/dwarf2/lang-cpp17.C: Add -gno-strict-dwarf to
	dg-options.  Check also for DW_AT_language_{name,version} values.
	* g++.dg/debug/dwarf2/lang-cpp20.C: Likewise.
	* g++.dg/debug/dwarf2/lang-cpp23.C: New test.
2025-01-08 10:57:50 +01:00
Jakub Jelinek
6441eb6dc0 Update copyright years. 2025-01-02 11:59:57 +01:00
GCC Administrator
4bbf650e4b Daily bump. 2024-12-30 00:17:12 +00:00
John David Anglin
9fbf4a6adf Add support to provide libiberty mkstemps in gcc
2024-12-28  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	PR target/118121
	* configure.ac: Check for mkstemps declaration.
	* configure: Regenerate.
	* config.in: Regenerate.

include/ChangeLog:

	* libiberty.h (mkstemps): Declare
2024-12-29 14:38:09 -05:00
GCC Administrator
a095d720ac Daily bump. 2024-11-24 00:18:09 +00:00
Jakub Jelinek
c4073a3d15 include: Add yet another DW_LANG_* enumerator from https://dwarfstd.org/languages.html
Another DW_LANG_* code has been added recently...

2024-11-23  Jakub Jelinek  <jakub@redhat.com>

	* dwarf2.h (enum dwarf_source_language): Add DW_LANG_Fortran23
	enumerator.
2024-11-23 13:02:31 +01:00
GCC Administrator
8223841bda Daily bump. 2024-11-23 00:20:45 +00:00
Tobias Burnus
8f0c8e577a OpenMP: 'interop' construct - add C/C++ parser support, improve Fortran parsing
Add middle end support for the 'interop' directive and the 'init', 'use',
and 'destroy' clauses - but fail with a sorry, unimplemented in gimplify.cc.

For Fortran, generate the tree code, update the internal representation,
add some more diagnostic checks and update for newer specification changes
('fr' only takes a single value, but it integer expressions are permitted
again [like with the old syntax] not only constant identifiers).

For C and C++, this patch adds the full parser support for 'interop'.

Still missing is actually handling the directive in the middle end and
in libgomp.

The GOMP_INTEROP_IFR_* internal values have been changed to have space
for vendor specific values that are adjacent to the existing values
but negative, if needed.

gcc/c-family/ChangeLog:

	* c-common.h (enum c_omp_region_type): Add C_ORT_INTEROP
	and C_ORT_OMP_INTEROP.
	(c_omp_interop_t_p): New prototype.
	* c-omp.cc (c_omp_interop_t_p): Check whether the type is
	omp_interop_t.
	(c_omp_directives): Uncomment 'interop'.
	* c-pragma.cc (omp_pragmas): Add 'interop'.
	* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_INTEROP.
	(enum pragma_omp_clause): Add init, use, and destroy clauses.

gcc/c/ChangeLog:

	* c-parser.cc (INCLUDE_STRING): Define.
	(c_parser_pragma): Handle 'interop' directive.
	(c_parser_omp_clause_name): Handle init, use, and destroy clauses.
	(c_parser_omp_all_clauses): Likewise; use C_ORT_OMP_INTEROP, if
	'use' is permitted, for c_finish_omp_clauses.
	(c_parser_omp_clause_destroy, c_parser_omp_modifier_prefer_type,
	c_parser_omp_clause_init, c_parser_omp_clause_use,
	OMP_INTEROP_CLAUSE_MASK, c_parser_omp_interop): New.
	* c-typeck.cc (c_finish_omp_clauses): Add missing OPT_Wopenmp to
	a warning; handle new clauses.

gcc/cp/ChangeLog:

	* parser.cc (INCLUDE_STRING): Define.
	(cp_parser_omp_clause_name): Handle init, use, and destroy clauses.
	(cp_parser_omp_all_clauses): Likewise; use C_ORT_OMP_INTEROP, if
	'use' is permitted, for c_finish_omp_clauses.
	(cp_parser_omp_modifier_prefer_type, cp_parser_omp_clause_init,
	OMP_INTEROP_CLAUSE_MASK, cp_parser_omp_interop): New.
	(cp_parser_pragma): Handle 'interop' directive.
	* pt.cc (tsubst_omp_clauses): Handle init, use, and destroy clauses.
	(tsubst_stmt): Handle OMP_INTEROP.
	* semantics.cc (cp_omp_init_prefer_type_update): New.
	(finish_omp_clauses): Handle  init, use, and destroy clauses
	and add clause check for 'depend' on 'interop'.

gcc/fortran/ChangeLog:

	* 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.

gcc/ChangeLog:

	* gimplify.cc (gimplify_expr): Handle OMP_INTEROP by printing
	"sorry, uninplemented".
	* omp-api.h (omp_get_fr_id_from_name): Change return type to
	'char'.
	* omp-general.cc (omp_get_fr_id_from_name): Likewise; return
	GOMP_INTEROP_IFR_UNKNOWN not 0 if not found.
	(omp_get_name_from_fr_id): Return "<unknown>" not NULL
	if not found (used for dumps).
	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DESTROY,
	OMP_CLAUSE_USE, and OMP_CLAUSE_INIT.
	* tree-pretty-print.cc (dump_omp_init_prefer_type): New.
	(dump_omp_clause): Handle init, use and destroy clauses.
	(dump_generic_node): Handle interop directive.
	* tree.cc (omp_clause_num_ops, omp_clause_code_name): Add new
	init/use/destroy clauses.
	* tree.def (OACC_LOOP): Fix comment.
	(OMP_INTEROP): Add.
	* tree.h (OMP_INTEROP_CLAUSES, OMP_CLAUSE_INIT_TARGET,
	OMP_CLAUSE_INIT_TARGETSYNC, OMP_CLAUSE_INIT_PREFER_TYPE): New.

include/ChangeLog:

	* gomp-constants.h (GOMP_INTEROP_IFR_NONE): Rename ...
	(GOMP_INTEROP_IFR_UNKNOWN): ... to this. And change value.
	(GOMP_INTEROP_IFR_SEPARATOR): Likewise.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/interop-1.f90: Update for parser changes,
	spec changes and add new tests.
	* gfortran.dg/gomp/interop-2.f90: Likewise.
	* gfortran.dg/gomp/interop-3.f90: Likewise.
	* c-c++-common/gomp/interop-1.c: New test.
	* c-c++-common/gomp/interop-2.c: New test.
	* c-c++-common/gomp/interop-3.c: New test.
	* c-c++-common/gomp/interop-4.c: New test.
	* g++.dg/gomp/interop-5.C: New test.
	* gfortran.dg/gomp/interop-4.f90: New test.
2024-11-22 15:30:53 +01:00