[clang] [llvm] [RFC][CodeGen] Add generic target feature checks for intrinsics (PR #201470)
Shilei Tian via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 24 08:30:27 PDT 2026
================
@@ -25,6 +26,23 @@ TargetSubtargetInfo::TargetSubtargetInfo(
TargetSubtargetInfo::~TargetSubtargetInfo() = default;
+bool TargetSubtargetInfo::isIntrinsicSupported(unsigned IntrinsicID,
+ const CallBase &CB) const {
+ StringRef RequiredFeatures = Intrinsic::getRequiredTargetFeatures(
+ static_cast<Intrinsic::ID>(IntrinsicID));
+
+ if (RequiredFeatures.empty())
+ return true;
+
+ if (RequiredFeatures == Intrinsic::CustomTargetFeatures)
+ return isIntrinsicSupportedByTarget(IntrinsicID, CB);
+
+ auto [It, Inserted] = IntrinsicSupportCache.try_emplace(IntrinsicID);
+ if (Inserted)
+ It->second = checkFeatureExpression(RequiredFeatures);
----------------
shiltian wrote:
Right, but I see two issues:
- How do we represent the case where an intrinsic is always supported, but different subtargets use different manglings, or support different arguments? In that case, we'd need to explicitly introduce an extra target feature and add it to all subtargets.
- Wouldn't it also be more expensive if an intrinsic is not supported at all, since it adds an extra layer of checks?
https://github.com/llvm/llvm-project/pull/201470
More information about the cfe-commits
mailing list