Query supported llvm intrinsic calls during runtime.

Hello,

I have a frontend which creates LLVM IR and uses LLVM optimizations and codegen. Is there someway to query LLVM during runtime if a particular intrinsic is supported?

For example- during runtime user says call the following intrinsic - ‘llvm.foo(<8 x i64>)’. I’m looking for a way to verify that llvm.foo(<8 x i64>)’. is a valid llvm intrinsic before creating IR/inserting in IR.

Regards,
Deepak

Are you asking about target independent intrinsics or target specific intrinsics?

Both. Target specific intrinsics especially are important but ideally I’d like to be able to query for both. The idea is to enable to directly call any available llvm intrinsic.

Regards,
Deepak

Does Intrinsic::getIntrinsicInfoTableEntries() + Intrinsic::matchIntrinsicSignature() do what you’re looking for?

Thank you! That looks like it should do the trick assuming it checks for both target specific and target independent intrinsics.

Regards,
Deepak

That doesn’t check for target features being enabled for target specific intrinsics. I believe Andy’s suggestion will just check if the types are valid.

Seems like it’s more complicated than just checking intrinsics/target features. Some intrinsics seem to require specific opt passes to lower.

For eg. https://llvm.org/docs/LangRef.html#matrix-intrinsics : it doesn’t say anything in the doc but

llc with no opt pass - https://godbolt.org/z/dWYddx

lowering with opt pass : https://godbolt.org/z/18n69T

That raises the question – is there any doc available with similar exceptions which require additional passes to be run for codegen?

-Deepak