[flang-commits] [flang] [llvm] [clang] [AArch64][Driver] Better handling of target feature dependencies (PR #78270)
Tomas Matheson via flang-commits
flang-commits at lists.llvm.org
Wed Jan 17 08:26:56 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);
+
+ // Special cases for dependencies which vary depending on the base
+ // architecture version.
+ if (BaseArch) {
+ // +sve implies +f32mm if the base architecture is v8.6A+ or v9.1A+
+ // It isn't the case in general that sve implies both f64mm and f32mm
+ if (E == AEK_SVE && BaseArch->is_superset(ARMV8_6A))
+ enable(AEK_F32MM);
+
+ // +fp16 implies +fp16fml for v8.4A+, but not v9.0-A+
+ if (E == AEK_FP16 && BaseArch->is_superset(ARMV8_4A) &&
+ !BaseArch->is_superset(ARMV9A))
+ enable(AEK_FP16FML);
+
+ // For all architectures, +crypto enables +aes and +sha2.
+ if (E == AEK_CRYPTO) {
+ enable(AEK_AES);
+ enable(AEK_SHA2);
+ }
+
+ // For v8.4A+ and v9.0A+, +crypto also enables +sha3 and +sm4.
+ if (E == AEK_CRYPTO && BaseArch->is_superset(ARMV8_4A)) {
+ enable(AEK_SHA3);
+ enable(AEK_SM4);
+ }
+ }
----------------
tmatheson-arm wrote:
This logic is so much nicer than what we currently have.
https://github.com/llvm/llvm-project/pull/78270
More information about the flang-commits
mailing list