Skip to content

Commit ad06c49

Browse files
[FMV] Refine scope and signature rules for multiversioned functions
Changes the Function multiversioning rules for `target_version` such that the signature and scope for a set of FMV functions is that of the default version. This patch also adds some examples documenting the rules and behavior.
1 parent 11ce13e commit ad06c49

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

main/acle.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ Armv8.4-A [[ARMARMv84]](#ARMARMv84). Support is added for the Dot Product intrin
430430
* Changed `__ARM_NEON_SVE_BRIDGE` to refer to the availability of the
431431
[`arm_neon_sve_bridge.h`](#arm_neon_sve_bridge.h) header file, rather
432432
than the [NEON-SVE bridge](#neon-sve-bridge) intrinsics.
433+
* Refined function versioning scope and signature rules to use the default
434+
version scope and signature.
433435

434436
### References
435437

@@ -2685,6 +2687,9 @@ The following attributes trigger the multi version code generation:
26852687
* If only the `default` version exist it should be linked directly.
26862688
* FMV may be disabled in compile time by a compiler flag. In this
26872689
case the `default` version shall be used.
2690+
* The scope for calling the versioned function is the scope of the
2691+
default version.
2692+
* All function versions must be declared at the same scope level.
26882693

26892694
[^fmv-note-names]: For example the `sve_bf16` feature depends on `sve`
26902695
but it is enough to say `target_version("sve_bf16")` in the code.
@@ -2699,11 +2704,26 @@ following:
26992704
in one of the translation units.
27002705
* Implicitly, without this attribute,
27012706
* or explicitly providing the `default` in the attribute.
2702-
* All instances of the versions shall share the same function
2703-
signature and calling convention.
2707+
* The default version signature is the signature for calling
2708+
the multiversioned functions.
2709+
* Non-default versions shall share the same calling convention
2710+
of the default version and have a type that is convertible to the type
2711+
of the default version.
2712+
27042713
* All the function versions must be declared at the translation
27052714
unit in which the definition of the default version resides.
27062715

2716+
For example, the below is valid and 2 is passed as the
2717+
value for `c` when calling `f`.
2718+
2719+
```C
2720+
int __attribute__((target_version("simd"))) f (int c = 1);
2721+
int __attribute__((target_version("default"))) f (int c = 2);
2722+
int __attribute__((target_version("sve"))) f (int c = 3);
2723+
2724+
int g() { return f(); }
2725+
```
2726+
27072727
The attribute `__attribute__((target_clones("name",...)))` expresses the
27082728
following:
27092729

0 commit comments

Comments
 (0)