BeMg wrote:
This patch support the `target_clones` function attribute and function
multiversioning feature for RISC-V target. It will generate the ifunc resolver
function for the function that declared with target_clones attribute.
The resolver function will check the version support by runtime object
`__riscv_feature_bits`.
For example:
```
__attribute__((target_clones("default", "arch=+ver1", "arch=+ver2"))) int bar()
{
return 1;
}
```
the corresponding resolver will be like:
```
bar.resolver() {
// Check arch=+ver1
if (__riscv_feature_bits.length > MAX_GROUPID_IN_VER1 &&
(__riscv_feature_bits.features[0] & BITMASK_OF_VERSION1) ==
BITMASK_OF_VERSION1) {
return bar.arch=+ver1;
} else {
// Check arch=+ver2
if (__riscv_feature_bits.length > MAX_GROUPID_IN_VER2 &&
(__riscv_feature_bits.features[0] & BITMASK_OF_VERSION2) ==
BITMASK_OF_VERSION2) {
return bar.arch=+ver2;
} else {
// Default
return bar.default;
}
}
}
```
https://github.com/llvm/llvm-project/pull/85786
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits