[clang] [RISCV][FMV] Support target_clones (PR #85786)
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 22 10:43:29 PDT 2024
================
@@ -2877,10 +2877,144 @@ void CodeGenFunction::EmitMultiVersionResolver(
case llvm::Triple::aarch64:
EmitAArch64MultiVersionResolver(Resolver, Options);
return;
+ case llvm::Triple::riscv32:
+ case llvm::Triple::riscv64:
+ EmitRISCVMultiVersionResolver(Resolver, Options);
+ return;
default:
- assert(false && "Only implemented for x86 and AArch64 targets");
+ assert(false && "Only implemented for x86, AArch64 and RISC-V targets");
+ }
+}
+
+static int getPrioiryFromAttrString(StringRef AttrStr) {
+ SmallVector<StringRef, 8> Attrs;
+
+ AttrStr.split(Attrs, ";");
+
+ // Default Pri is zero.
+ int Pri = 0;
+ for (auto Attr : Attrs) {
+ if (Attr.starts_with("priority=")) {
+ Attr.consume_front("priority=");
----------------
topperc wrote:
consume_front returns a bool if it consumes the string so I think you can write
```
if (Attr.consume_front("priority=")) {
int Result;
if (!Attr.getAsInteger(0, Result)) {
Pri = **Result;
}
```
https://github.com/llvm/llvm-project/pull/85786
More information about the cfe-commits
mailing list