[clang] [llvm] [AArch64] Add a check for invalid default features (PR #104435)

Lucas Duarte Prates via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 15 09:07:09 PDT 2024


================
@@ -19,10 +19,38 @@
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 #include <cstdint>
+#include <set>
 #include <string>
 
 using namespace llvm;
 
+/// Collect the full set of implied features for a SubtargetFeature.
+static void CollectImpliedFeatures(std::set<Record *> &SeenFeats, Record *Rec) {
+  assert(Rec->isSubClassOf("SubtargetFeature") &&
+         "Rec is not a SubtargetFeature");
+
+  SeenFeats.insert(Rec);
+  for (Record *Implied : Rec->getValueAsListOfDefs("Implies"))
+    CollectImpliedFeatures(SeenFeats, Implied);
+}
+
+static void CheckFeatureTree(Record *Root) {
+  std::set<Record *> SeenFeats;
+  CollectImpliedFeatures(SeenFeats, Root);
+
+  // For processors, check that each of the mandatory (implied) features which
----------------
pratlucas wrote:

Nit: this seems to be covering architecture versions rather than processors.

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


More information about the cfe-commits mailing list