[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


================
@@ -308,6 +312,104 @@ inline constexpr ExtensionInfo Extensions[] = {
 };
 // clang-format on
 
+struct ExtensionSet {
+  // Set of extensions which are currently enabled.
+  ExtensionBitset Enabled;
+  // Set of extensions which have been enabled or disabled at any point. Used
+  // to avoid cluttering the cc1 command-line with lots of unneeded features.
+  ExtensionBitset Touched;
+  // Base architecture version, which we need to know because some feature
+  // dependencies change depending on this.
+  const ArchInfo *BaseArch;
+
+  ExtensionSet() : Enabled(), Touched(), BaseArch(nullptr) {}
+
+  // Enable the given architecture extension, and any other extensions it
+  // depends on. Does not change the base architecture, or follow dependencies
+  // between features which are only related by required arcitecture versions.
+  void enable(ArchExtKind E);
+
+  // Disable the given architecture extension, and any other extensions which
+  // depend on it. Does not change the base architecture, or follow
+  // dependencies between features which are only related by required
+  // arcitecture versions.
+  void disable(ArchExtKind E);
+
+  // Add default extensions for the given CPU. Records the base architecture,
+  // to later resolve dependencies which depend on it.
+  void addCPUDefaults(const CpuInfo &CPU);
+
+  // Add default extensions for the given architecture version. Records the
+  // base architecture, to later resolve dependencies which depend on it.
+  void addArchDefaults(const ArchInfo &Arch);
+
+  // Add or remove a feature based on a modifier string. The string must be of
----------------
tmatheson-arm wrote:

I'm a bit unclear on the terminology. Often "extension" is taken to mean something which has an entry in `ArchExtKind`, whereas "feature" is an LLVM backend feature. In the Arm ARM they are referred to as extensions and there is no concept of features.

Should this be "Add or remove an extension"?

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


More information about the cfe-commits mailing list