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.
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.
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.
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?