[clang] [llvm] [RFC][CodeGen] Add generic target feature checks for intrinsics (PR #201470)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 30 01:30:14 PDT 2026
================
@@ -331,15 +331,108 @@ bool MCSubtargetInfo::checkFeatures(StringRef FS) const {
"Feature flags should start with '+' or '-'");
const SubtargetFeatureKV *FeatureEntry =
Find(SubtargetFeatures::StripFlag(F), ProcFeatures);
- if (!FeatureEntry)
- report_fatal_error(Twine("'") + F +
- "' is not a recognized feature for this target");
+ if (!FeatureEntry) {
+ reportFatalInternalError(Twine("'") + F +
+ "' is not a recognized feature for this target");
+ }
return FeatureBits.test(FeatureEntry->Value) ==
SubtargetFeatures::isEnabled(F);
});
}
+static bool hasFeature(StringRef Feature, const FeatureBitset &FeatureBits,
+ ArrayRef<SubtargetFeatureKV> ProcFeatures) {
+ bool ShouldBeEnabled = true;
+ if (!Feature.consume_front("+") && Feature.consume_front("-"))
+ ShouldBeEnabled = false;
+
+ const SubtargetFeatureKV *FeatureEntry = Find(Feature, ProcFeatures);
+ if (!FeatureEntry) {
+ reportFatalInternalError(Twine("'") + Feature +
+ "' is not a recognized feature for this target");
+ }
+
+ return FeatureBits.test(FeatureEntry->Value) == ShouldBeEnabled;
+}
+
+namespace {
+class FeatureExpressionParser {
----------------
arsenm wrote:
I'm thinking we ought to move all of the SubtargetFeature handling into TargetParser
https://github.com/llvm/llvm-project/pull/201470
More information about the cfe-commits
mailing list