gcc/libgcc
Andrew Carlotti 0cfde688e2 [aarch64] Add function multiversioning support
This adds initial support for function multiversioning on aarch64 using
the target_version and target_clones attributes.  This loosely follows
the Beta specification in the ACLE [1], although with some differences
that still need to be resolved (possibly as follow-up patches).

Existing function multiversioning implementations are broken in various
ways when used across translation units.  This includes placing
resolvers in the wrong translation units, and using symbol mangling that
callers to unintentionally bypass the resolver in some circumstances.
Fixing these issues for aarch64 will require modifications to our ACLE
specification.  It will also require further adjustments to existing
middle end code, to facilitate different mangling and resolver
placement while preserving existing target behaviours.

The list of function multiversioning features specified in the ACLE is
also inconsistent with the list of features supported in target option
extensions.  I intend to resolve some or all of these inconsistencies at
a later stage.

The target_version attribute is currently only supported in C++, since
this is the only frontend with existing support for multiversioning
using the target attribute.  On the other hand, this patch happens to
enable multiversioning with the target_clones attribute in Ada and D, as
well as the entire C family, using their existing frontend support.

This patch also does not support the following aspects of the Beta
specification:

- The target_clones attribute should allow an implicit unlisted
  "default" version.
- There should be an option to disable function multiversioning at
  compile time.
- Unrecognised target names in a target_clones attribute should be
  ignored (with an optional warning).  This current patch raises an
  error instead.

[1] https://github.com/ARM-software/acle/blob/main/main/acle.md#function-multi-versioning

gcc/ChangeLog:

	* config/aarch64/aarch64-feature-deps.h (fmv_deps_<FEAT_NAME>):
	Define aarch64_feature_flags mask foreach FMV feature.
	* config/aarch64/aarch64-option-extensions.def: Use new macros
	to define FMV feature extensions.
	* config/aarch64/aarch64.cc (aarch64_option_valid_attribute_p):
	Check for target_version attribute after processing target
	attribute.
	(aarch64_fmv_feature_data): New.
	(aarch64_parse_fmv_features): New.
	(aarch64_process_target_version_attr): New.
	(aarch64_option_valid_version_attribute_p): New.
	(get_feature_mask_for_version): New.
	(compare_feature_masks): New.
	(aarch64_compare_version_priority): New.
	(build_ifunc_arg_type): New.
	(make_resolver_func): New.
	(add_condition_to_bb): New.
	(dispatch_function_versions): New.
	(aarch64_generate_version_dispatcher_body): New.
	(aarch64_get_function_versions_dispatcher): New.
	(aarch64_common_function_versions): New.
	(aarch64_mangle_decl_assembler_name): New.
	(TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P): New implementation.
	(TARGET_OPTION_EXPANDED_CLONES_ATTRIBUTE): New implementation.
	(TARGET_OPTION_FUNCTION_VERSIONS): New implementation.
	(TARGET_COMPARE_VERSION_PRIORITY): New implementation.
	(TARGET_GENERATE_VERSION_DISPATCHER_BODY): New implementation.
	(TARGET_GET_FUNCTION_VERSIONS_DISPATCHER): New implementation.
	(TARGET_MANGLE_DECL_ASSEMBLER_NAME): New implementation.
	* config/aarch64/aarch64.h (TARGET_HAS_FMV_TARGET_ATTRIBUTE):
	Set target macro.
	* config/arm/aarch-common.h (enum aarch_parse_opt_result): Add
	new value to report duplicate FMV feature.
	* common/config/aarch64/cpuinfo.h: New file.

libgcc/ChangeLog:

	* config/aarch64/cpuinfo.c (enum CPUFeatures): Move to shared
	copy in gcc/common

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/options_set_17.c: Reorder expected flags.
	* gcc.target/aarch64/cpunative/native_cpu_0.c: Ditto.
	* gcc.target/aarch64/cpunative/native_cpu_13.c: Ditto.
	* gcc.target/aarch64/cpunative/native_cpu_16.c: Ditto.
	* gcc.target/aarch64/cpunative/native_cpu_17.c: Ditto.
	* gcc.target/aarch64/cpunative/native_cpu_18.c: Ditto.
	* gcc.target/aarch64/cpunative/native_cpu_19.c: Ditto.
	* gcc.target/aarch64/cpunative/native_cpu_20.c: Ditto.
	* gcc.target/aarch64/cpunative/native_cpu_21.c: Ditto.
	* gcc.target/aarch64/cpunative/native_cpu_22.c: Ditto.
	* gcc.target/aarch64/cpunative/native_cpu_6.c: Ditto.
	* gcc.target/aarch64/cpunative/native_cpu_7.c: Ditto.
2023-12-16 00:41:22 +00:00
..
config [aarch64] Add function multiversioning support 2023-12-16 00:41:22 +00:00
soft-fp libgcc: Add {unsigned ,}__int128 <-> _Decimal{32,64,128} conversion support [PR65833] 2023-11-09 09:14:07 +01:00
ChangeLog Daily bump. 2023-12-12 00:17:22 +00:00
config.host arm: libgcc: provide implementations of __sync_synchronize 2023-11-24 14:15:26 +00:00
config.in libgcc: Fix config.in 2023-12-08 12:35:40 +00:00
configure libgcc: aarch64: Configure check for __getauxval 2023-12-08 11:29:06 +00:00
configure.ac libgcc: aarch64: Configure check for __getauxval 2023-12-08 11:29:06 +00:00
crtstuff.c Update copyright years. 2023-01-16 11:52:17 +01:00
dfp-bit.c Update copyright years. 2023-01-16 11:52:17 +01:00
dfp-bit.h Update copyright years. 2023-01-16 11:52:17 +01:00
divmod.c Update copyright years. 2023-01-16 11:52:17 +01:00
emutls.c libgcc: Avoid -Wbuiltin-declaration-mismatch warnings in emutls.c 2023-12-06 12:27:12 +01:00
enable-execute-stack-empty.c
enable-execute-stack-mprotect.c Update copyright years. 2023-01-16 11:52:17 +01:00
find-symver.awk Update copyright years. 2023-01-16 11:52:17 +01:00
fixed-bit.c Update copyright years. 2023-01-16 11:52:17 +01:00
fixed-bit.h Update copyright years. 2023-01-16 11:52:17 +01:00
fixed-obj.mk
floatunsidf.c
floatunsisf.c
floatunsitf.c
floatunsixf.c
fp-bit.c Update copyright years. 2023-01-16 11:52:17 +01:00
fp-bit.h Update copyright years. 2023-01-16 11:52:17 +01:00
gbl-ctors.h Update copyright years. 2023-01-16 11:52:17 +01:00
gcov.h Update copyright years. 2023-01-16 11:52:17 +01:00
gen-fixed.sh
generic-morestack-thread.c Update copyright years. 2023-01-16 11:52:17 +01:00
generic-morestack.c Update copyright years. 2023-01-16 11:52:17 +01:00
generic-morestack.h Update copyright years. 2023-01-16 11:52:17 +01:00
gstdint.h
gthr-posix.h libgfortran: Replace mutex with rwlock 2023-12-11 09:43:59 -08:00
gthr-single.h Update copyright years. 2023-01-16 11:52:17 +01:00
gthr.h Update copyright years. 2023-01-16 11:52:17 +01:00
hardcfr.c libgcc: mark __hardcfr_check_fail as always_inline 2023-11-23 17:31:40 +01:00
libgcc2.c libgcc _BitInt helper documentation [PR102989] 2023-09-06 17:42:37 +02:00
libgcc2.h Introduce strub: machine-independent stack scrubbing 2023-12-05 21:07:36 -03:00
libgcc-std.ver.in Introduce strub: machine-independent stack scrubbing 2023-12-05 21:07:36 -03:00
libgcov-driver-system.c Update copyright years. 2023-01-16 11:52:17 +01:00
libgcov-driver.c Update copyright years. 2023-01-16 11:52:17 +01:00
libgcov-interface.c libgcov: Call __builtin_fork instead of fork 2023-12-08 16:27:55 +01:00
libgcov-merge.c Update copyright years. 2023-01-16 11:52:17 +01:00
libgcov-profiler.c Update copyright years. 2023-01-16 11:52:17 +01:00
libgcov-util.c Update copyright years. 2023-01-16 11:52:17 +01:00
libgcov.h gcov: Fix use of __LIBGCC_HAVE_LIBATOMIC 2023-12-01 09:54:24 +01:00
Makefile.in strub: enable conditional support 2023-12-07 12:58:20 -03:00
memcmp.c
memcpy.c
memmove.c
memset.c
mkheader.sh Update copyright years. 2023-01-16 11:52:17 +01:00
mkmap-flat.awk Update copyright years. 2023-01-16 11:52:17 +01:00
mkmap-symver.awk Update copyright years. 2023-01-16 11:52:17 +01:00
offloadstuff.c openmp: Add support for the 'indirect' clause in C/C++ 2023-11-07 15:44:50 +00:00
shared-object.mk
siditi-object.mk
static-object.mk
strub.c Introduce strub: machine-independent stack scrubbing 2023-12-05 21:07:36 -03:00
sync.c Update copyright years. 2023-01-16 11:52:17 +01:00
udivhi3.c Update copyright years. 2023-01-16 11:52:17 +01:00
udivmod.c Update copyright years. 2023-01-16 11:52:17 +01:00
udivmodhi4.c Update copyright years. 2023-01-16 11:52:17 +01:00
udivmodsi4.c Update copyright years. 2023-01-16 11:52:17 +01:00
unwind-arm-common.inc Update copyright years. 2023-01-16 11:52:17 +01:00
unwind-c.c Update copyright years. 2023-01-16 11:52:17 +01:00
unwind-compat.c Update copyright years. 2023-01-16 11:52:17 +01:00
unwind-compat.h Update copyright years. 2023-01-16 11:52:17 +01:00
unwind-dw2-btree.h Update copyright years. 2023-01-16 11:52:17 +01:00
unwind-dw2-execute_cfa.h libgcc: Fix uninitialized RA signing on AArch64 [PR107678] 2023-01-18 12:20:35 +00:00
unwind-dw2-fde-compat.c Update copyright years. 2023-01-16 11:52:17 +01:00
unwind-dw2-fde-dip.c libgcc: Fix -Wint-conversion warning in find_fde_tail 2023-07-11 06:19:39 +02:00
unwind-dw2-fde.c preserve base pointer for __deregister_frame [PR110956] 2023-08-11 09:20:27 -06:00
unwind-dw2-fde.h Update copyright years. 2023-01-16 11:52:17 +01:00
unwind-dw2.c libgcc: Fix uninitialized RA signing on AArch64 [PR107678] 2023-01-18 12:20:35 +00:00
unwind-dw2.h libgcc: Fix uninitialized RA signing on AArch64 [PR107678] 2023-01-18 12:20:35 +00:00
unwind-generic.h Update copyright years. 2023-01-16 11:52:17 +01:00
unwind-pe.h [committed] Fix build of libgcc on ports using FDPIC 2023-12-02 22:45:48 -07:00
unwind-seh.c Update copyright years. 2023-01-16 11:52:17 +01:00
unwind-sjlj.c Update copyright years. 2023-01-16 11:52:17 +01:00
unwind.inc Update copyright years. 2023-01-16 11:52:17 +01:00
vtv_end_preinit.c Update copyright years. 2023-01-16 11:52:17 +01:00
vtv_end.c Update copyright years. 2023-01-16 11:52:17 +01:00
vtv_start_preinit.c Update copyright years. 2023-01-16 11:52:17 +01:00
vtv_start.c Update copyright years. 2023-01-16 11:52:17 +01:00