Skip to content

Commit d294acf

Browse files
Add FMV priority syntax (#404)
This is a PR to implement option 3 of #403 proposed by @labrinea . It adds the proposed syntax, with higher priority values taking precedence.
1 parent 50604e1 commit d294acf

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

main/acle.md

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ Armv8.4-A [[ARMARMv84]](#ARMARMv84). Support is added for the Dot Product intrin
446446
* Added `svdot[_n_f16_mf8]_fpm` and `svdot[_n_f32_mf8]_fpm`.
447447
* Added Guarded Control Stack (GCS) at
448448
[**Beta**](#current-status-and-anticipated-changes) quality level.
449+
* Add Function Multi Versioning feature priority syntax.
449450

450451
#### Changes between ACLE Q4 2024 and ACLE Q2 2025
451452

@@ -2755,8 +2756,8 @@ function may be in the final binary. The compiler generates all
27552756
supported versions and the runtime makes the selection at load time.
27562757

27572758
The following attributes trigger the multi version code generation:
2758-
`__attribute__((target_version("name")))` and
2759-
`__attribute__((target_clones("name",...)))`.
2759+
`__attribute__((target_version("<target version string>")))` and
2760+
`__attribute__((target_clones("<target version string>",...)))`.
27602761

27612762
* Functions are allowed to have the same name and signature when
27622763
annotated with these attributes.
@@ -2765,7 +2766,6 @@ The following attributes trigger the multi version code generation:
27652766
section.
27662767
* The `default` version means the version of the function that would
27672768
be generated without these attributes.
2768-
* The dependent features could be joined by the `+` sign.
27692769
* None of these attributes enable the corresponding ACLE feature(s)
27702770
associated to the `name` expressed in the attribute.
27712771
* These attributes have no effect on the calling convention.
@@ -2789,7 +2789,7 @@ The following attributes trigger the multi version code generation:
27892789
* or, as a function annotated with `target_clones(...)` where one
27902790
of the versions is `default`.
27912791

2792-
The attribute `__attribute__((target_version("name")))` expresses the
2792+
The attribute `__attribute__((target_version("<target version string>")))` expresses the
27932793
following:
27942794

27952795
* When applied to a function it becomes one of the versions.
@@ -2816,7 +2816,7 @@ int f (int c = 1);
28162816
int __attribute__((target_version("default"))) f (int c = 2);
28172817
```
28182818

2819-
The attribute `__attribute__((target_clones("name",...)))` expresses the
2819+
The attribute `__attribute__((target_clones("<target version string>",...)))` expresses the
28202820
following:
28212821

28222822
* when applied to a function the compiler emits multiple versions
@@ -2841,6 +2841,32 @@ For example, it can be implemented as:
28412841
#define __FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL __ARM_ACLE_VERSION(2024, 3, 0)
28422842
```
28432843

2844+
### Target version strings
2845+
2846+
A target version string has the following form:
2847+
2848+
```
2849+
<target version string> := 'default'
2850+
| <version string>
2851+
<version string> := <arch strings> ';' <priority string>
2852+
| <arch strings>
2853+
<priority string> := 'priority=[1-255]'
2854+
<arch strings> := <arch strings> '+' arch extension
2855+
| arch extension
2856+
```
2857+
2858+
where `arch extension` is any Names value from the Mapping table below.
2859+
2860+
Valid string examples are given below
2861+
2862+
```
2863+
default
2864+
dotprod
2865+
dotprod+flagm
2866+
sve;priority=5
2867+
sve2+sme2;priority=23
2868+
```
2869+
28442870
### Name mangling
28452871

28462872
The `"default"` version is mangled with `".default"` on top of the
@@ -2857,6 +2883,8 @@ the [[cxxabi]](#cxxabi), and it is defined as follows:
28572883
<vendor specific suffix> := `_` followed by token obtained from the tables below and prefixed with `M`
28582884
```
28592885

2886+
Priority values do not affect mangling.
2887+
28602888
If multiple features are requested then those shall be appended in lexicographic
28612889
order and prefixed with `M`. The mangled name shall contain a unique set of
28622890
features (duplication of features is not allowed).
@@ -2990,11 +3018,19 @@ the selection algorithm is platform dependent, where with platform means
29903018
CPU/Vendor/OS as in the target triplet.
29913019
2. The selection is permanent for the
29923020
lifetime of the process.
2993-
3. Among any two versions, the higher priority version is determined by
2994-
identifying the highest priority feature that is specified in exactly one of
2995-
the versions, and selecting that version.
2996-
4. The selection algorithm must select the highest priority versions whose
2997-
dependent features are all available.
3021+
3. The selection algorithm must select the version with the highest
3022+
precedence whose dependent features are all available.
3023+
3024+
The precedence for two target version strings is determined by:
3025+
3026+
1. If both target version strings specify a `priority`, with different values,
3027+
then the version with the higher `priority` has precedence.
3028+
2. If only one target version string specifies a `priority`, this version has
3029+
precedence.
3030+
3. Otherwise, if neither target version string specifies a `priority` or both
3031+
specify the same value, then precedence is decided by identifying the highest
3032+
priority feature that is specified in exactly one of the versions, and selecting
3033+
that version.
29983034

29993035
## Weak linkage
30003036

0 commit comments

Comments
 (0)