[clang] [llvm] [RFC][CodeGen] Add generic target feature checks for intrinsics (PR #201470)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 23 06:26:58 PDT 2026


================
@@ -758,6 +758,14 @@ class TypeInfoGen<list<LLVMType> RetTypes, list<LLVMType> ParamTypes> {
 //  * ParamTypes is a list containing the parameter types expected for the
 //    intrinsic.
 //  * Properties can be set to describe the behavior of the intrinsic.
+//  * TargetFeatures is a target feature expression required by the intrinsic.
+//    The empty string means no target features are required. The expression
+//    uses feature names from the target's subtarget feature table. Comma means
+//    AND, | means OR, and parentheses group expressions. The special value
+//    "$custom" (Intrinsic::CustomTargetFeatures) indicates that support is
+//    decided by a target hook (TargetSubtargetInfo::isIntrinsicSupportedByTarget)
+//    rather than by evaluating a feature expression; use it when support depends
+//    on more than the subtarget features, e.g. a particular overload/mangling.
----------------
shiltian wrote:

Because verifier cannot be sub target dependent. I can think of two cases:

1) An intrinsic's argument is subtarget dependent. Say it accepts 0 and 1 on one subtarget, but can accept 0, 1 and 2 on another subtarget. The verifier can only check if the value is 0/1/2, but if the value is 2 on the target that doesn't accept that, we can't select it. I think we already have that kind of intrinsics for memory operations where there is an argument for some kind of controls.

2) Certain manglings of an intrinsic is sub target dependent. This is also not something that can be done by the verifier.

Overall, I think anything that is sub target dependent would fit this, because they can neither be verified by the verifier or be correctly selected.

https://github.com/llvm/llvm-project/pull/201470


More information about the llvm-commits mailing list