@@ -433,6 +433,8 @@ Armv8.4-A [[ARMARMv84]](#ARMARMv84). Support is added for the Dot Product intrin
433
433
than the [NEON-SVE bridge](#neon-sve-bridge) intrinsics.
434
434
* Removed extraneous `const` from SVE2.1 store intrinsics.
435
435
* Added [`__arm_agnostic`](#arm_agnostic) keyword attribute.
436
+ * Refined function versioning scope and signature rules to use the default
437
+ version scope and signature.
436
438
437
439
### References
438
440
@@ -2675,10 +2677,12 @@ The following attributes trigger the multi version code generation:
2675
2677
`__attribute__((target_version("name")))` and
2676
2678
`__attribute__((target_clones("name",...)))`.
2677
2679
2680
+ * Functions are allowed to have the same name and signature when
2681
+ annotated with these attributes.
2678
2682
* These attributes can be mixed with each other.
2683
+ * `name` is the dependent features from the tables below.
2679
2684
* The `default` version means the version of the function that would
2680
2685
be generated without these attributes.
2681
- * `name` is the dependent features from the tables below.
2682
2686
* The dependent features could be joined by the `+` sign.
2683
2687
* None of these attributes will enable the corresponding ACLE feature(s)
2684
2688
associated to the `name` expressed in the attribute.
@@ -2687,21 +2691,46 @@ The following attributes trigger the multi version code generation:
2687
2691
* If only the `default` version exist it should be linked directly.
2688
2692
* FMV may be disabled in compile time by a compiler flag. In this
2689
2693
case the `default` version shall be used.
2694
+ * A versioned function cannot be called unless the declaration of
2695
+ the default version is visible in the scope of the call site.
2696
+ * All function versions must be declared at the same scope level.
2697
+ * The default version signature is the signature for calling
2698
+ the multiversioned functions.
2699
+ * Non-default versions shall have a type that is convertible to the
2700
+ type of the default version.
2701
+ * All the function versions must be declared at the translation
2702
+ unit in which the definition of the default version resides.
2690
2703
2691
2704
The attribute `__attribute__((target_version("name")))` expresses the
2692
2705
following:
2693
2706
2694
- * when applied to a function it becomes one of the versions. Function
2695
- with the same name may exist with multiple versions in the same
2696
- or in different translation units.
2707
+ * When applied to a function it becomes one of the versions.
2708
+ * Multiple function versions may exist in the same or in different
2709
+ translation units.
2697
2710
* One `default` version of the function is required to be provided
2698
2711
in one of the translation units.
2699
2712
* Implicitly, without this attribute,
2700
2713
* or explicitly providing the `default` in the attribute.
2701
- * All instances of the versions shall share the same function
2702
- signature and calling convention.
2703
- * All the function versions must be declared at the translation
2704
- unit in which the definition of the default version resides.
2714
+
2715
+ For example, the below is valid and 2 is used as the default
2716
+ value for `c` when calling the multiversioned function `f`.
2717
+
2718
+ ```cpp
2719
+ int __attribute__((target_version("simd"))) f (int c = 1);
2720
+ int __attribute__((target_version("default"))) f (int c = 2);
2721
+ int __attribute__((target_version("sve"))) f (int c = 3);
2722
+
2723
+ int g() { return f(); }
2724
+ ```
2725
+
2726
+ Additionally, the below is not valid as the two statements declare
2727
+ the same entity (the `default` version of `f`) with conflicting
2728
+ signatures.
2729
+
2730
+ ```cpp
2731
+ int f (int c = 1);
2732
+ int __attribute__((target_version("default"))) f (int c = 2);
2733
+ ```
2705
2734
2706
2735
The attribute `__attribute__((target_clones("name",...)))` expresses the
2707
2736
following:
0 commit comments