================
@@ -126,6 +126,81 @@ bool CIRGenFunction::getAArch64SVEProcessedOperands(
return true;
}
+// Reinterpret the input predicate so that it can be used to correctly isolate
+// the elements of the specified datatype.
+mlir::Value CIRGenFunction::emitSVEpredicateCast(mlir::Value *pred,
+ unsigned minNumElts,
+ mlir::Location loc) {
+
+ // TODO: Handle "aarch64.svcount" once we get round to supporting SME.
+
+ auto retTy = cir::VectorType::get(builder.getUIntNTy(1), minNumElts,
+ /*is_scalable=*/true);
+ if (pred->getType() == retTy)
+ return *pred;
+
+ unsigned intID;
+ mlir::Type intrinsicTy;
+ switch (minNumElts) {
+ default:
+ llvm_unreachable("unsupported element count!");
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ intID = Intrinsic::aarch64_sve_convert_from_svbool;
+ intrinsicTy = retTy;
+ break;
+ case 16:
+ intID = Intrinsic::aarch64_sve_convert_to_svbool;
+ intrinsicTy = pred->getType();
+ break;
+ }
+
+ std::string llvmIntrName(Intrinsic::getBaseName(intID));
+ llvmIntrName.erase(0, /*std::strlen(".llvm")=*/5);
----------------
andykaylor wrote:
```suggestion
llvm::StringRef name = llvm::Intrinsic::getName(intrinsicID);
assert(name.starts_with("llvm.");
name = name.drop_front(/*strlen("llvm.")=*/5);
```
We should consider putting this in a helper function somewhere. Using StringRef
here avoids any possible memory shuffling and let's us verify the string prefix
is what we expect.
https://github.com/llvm/llvm-project/pull/175976
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits