[llvm] [clang] [flang] [AArch64][Driver] Better handling of target feature dependencies (PR #78270)

Tomas Matheson via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 08:26:54 PST 2024


================
@@ -150,3 +153,137 @@ void AArch64::PrintSupportedExtensions(StringMap<StringRef> DescMap) {
     }
   }
 }
+
+const llvm::AArch64::ExtensionInfo &
+lookupExtensionByID(llvm::AArch64::ArchExtKind ExtID) {
+  for (const auto &E : llvm::AArch64::Extensions)
+    if (E.ID == ExtID)
+      return E;
+  assert(false && "Invalid extension ID");
+}
+
+void AArch64::ExtensionSet::enable(ArchExtKind E) {
+  if (Enabled.test(E))
+    return;
+
+  LLVM_DEBUG(llvm::dbgs() << "Enable " << lookupExtensionByID(E).Name << "\n");
+
+  Touched.set(E);
+  Enabled.set(E);
+
+  // Recursively enable all features that this one depends on. This handles all
+  // of the simple cases, where the behaviour doesn't depend on the base
+  // architecture version.
+  for (auto Dep : ExtensionDependencies)
+    if (E == Dep.Later)
+      enable(Dep.Earlier);
----------------
tmatheson-arm wrote:

One concern I have is that `ExtensionDependencies` expresses the dependencies as a directed graph, but in reality we probably just want a tree, as this code assumes.

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


More information about the cfe-commits mailing list