[Mlir-commits] [llvm] [mlir] [LLVM] Refactor intrinsic validation (PR #194061)
Kirill Vedernikov
llvmlistbot at llvm.org
Thu Apr 30 06:26:23 PDT 2026
================
@@ -1088,77 +1084,90 @@ matchIntrinsicType(Type *Ty, ArrayRef<Intrinsic::IITDescriptor> &Infos,
llvm_unreachable("unhandled");
}
-Intrinsic::MatchIntrinsicTypesResult
-Intrinsic::matchIntrinsicSignature(FunctionType *FTy,
- ArrayRef<Intrinsic::IITDescriptor> &Infos,
- SmallVectorImpl<Type *> &OverloadTys) {
+/// Returns true if the intrinsic is a VarArg intrinsics. If \p Consume is true
+/// the IITDescriptor for the VarArg is consumed and removed from \p Infos, else
+/// it stays unchanged.
+static bool isIntrinsicVarArg(ArrayRef<Intrinsic::IITDescriptor> &Infos,
+ bool Consume) {
+ if (!Infos.empty() && Infos.back().Kind == Intrinsic::IITDescriptor::VarArg) {
+ if (Consume)
+ Infos.consume_back();
+ return true;
+ }
+ return false;
+}
+
+bool Intrinsic::matchIntrinsicSignature(
+ FunctionType *FTy, ArrayRef<Intrinsic::IITDescriptor> &Infos,
+ SmallVectorImpl<Type *> &OverloadTys, raw_ostream &OS) {
+ bool IsVarArg = isIntrinsicVarArg(Infos, /*Consume=*/true);
+
SmallVector<DeferredIntrinsicMatchPair, 2> DeferredChecks;
if (matchIntrinsicType(FTy->getReturnType(), Infos, OverloadTys,
- DeferredChecks, false))
- return MatchIntrinsicTypes_NoMatchRet;
+ DeferredChecks, false)) {
+ OS << "intrinsic has incorrect return type!";
+ return true;
+ }
unsigned NumDeferredReturnChecks = DeferredChecks.size();
- for (auto *Ty : FTy->params())
- if (matchIntrinsicType(Ty, Infos, OverloadTys, DeferredChecks, false))
- return MatchIntrinsicTypes_NoMatchArg;
+ for (Type *Ty : FTy->params())
----------------
kvederni wrote:
nit: do we need `auto` to `Type` change here?
https://github.com/llvm/llvm-project/pull/194061
More information about the Mlir-commits
mailing list