[clang] [llvm] [RFC][CodeGen] Add generic target feature checks for intrinsics (PR #201470)
Shilei Tian via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 23 06:51:09 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:
> This doesn't feel like it's adding any value to the "target feature" concept. One can easily identify intrinsics by name and verify a call, even without ever saying "$custom" in the TD file. That's basically the current practice.
The difference is, we have a unified place and infrastructure to do this instead of scattering the checks all over the place.
> Even with the new design for a callback, that callback can simply be called for every intrinsic, and internally it can recognize intrinsics that do need an extra check. So why bother saying "$custom"?
Without this special feature `$custom`, there would be no callback and everything would simply be just feature based check. Did I misunderstand your point?
https://github.com/llvm/llvm-project/pull/201470
More information about the cfe-commits
mailing list