[llvm] [AArch64][TargetParser] Move ExtensionDependencies into tablegen [NFC] (PR #93614)
Alexandros Lamprineas via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 01:46:20 PDT 2024
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/93614
>From 620c395f4b51da6a41cdedecb0643abf739c9f90 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas <alexandros.lamprineas at arm.com>
Date: Tue, 28 May 2024 20:27:23 +0100
Subject: [PATCH] [AArch64][TargetParser] Move ExtensionDependencies into
tablegen [NFC]
This patch generates ExtensionDependency pairs {Earlier, Later} inferred
by the 'Implies' field of every Extension defined in tablegen. Implied
Subtarget Features that are not Extensions are skipped.
---
.../llvm/TargetParser/AArch64TargetParser.h | 51 +------------------
llvm/lib/TargetParser/AArch64TargetParser.cpp | 18 ++++---
llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 14 +++++
3 files changed, 28 insertions(+), 55 deletions(-)
diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index b3fff3c99025a..5025ab2491de8 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -183,55 +183,8 @@ struct ExtensionDependency {
ArchExtKind Later;
};
-// clang-format off
-// Each entry here is a link in the dependency chain starting from the
-// extension that was added to the architecture first.
-inline constexpr ExtensionDependency ExtensionDependencies[] = {
- {AEK_FP, AEK_FP16},
- {AEK_FP, AEK_SIMD},
- {AEK_FP, AEK_JSCVT},
- {AEK_FP, AEK_FP8},
- {AEK_SIMD, AEK_CRYPTO},
- {AEK_SIMD, AEK_AES},
- {AEK_SIMD, AEK_SHA2},
- {AEK_SIMD, AEK_SHA3},
- {AEK_SIMD, AEK_SM4},
- {AEK_SIMD, AEK_RDM},
- {AEK_SIMD, AEK_DOTPROD},
- {AEK_SIMD, AEK_FCMA},
- {AEK_FP16, AEK_FP16FML},
- {AEK_FP16, AEK_SVE},
- {AEK_BF16, AEK_SME},
- {AEK_BF16, AEK_B16B16},
- {AEK_SVE, AEK_SVE2},
- {AEK_SVE, AEK_F32MM},
- {AEK_SVE, AEK_F64MM},
- {AEK_SVE2, AEK_SVE2P1},
- {AEK_SVE2, AEK_SVE2BITPERM},
- {AEK_SVE2, AEK_SVE2AES},
- {AEK_SVE2, AEK_SVE2SHA3},
- {AEK_SVE2, AEK_SVE2SM4},
- {AEK_SVE2, AEK_SMEFA64},
- {AEK_SVE2, AEK_SMEFA64},
- {AEK_SME, AEK_SME2},
- {AEK_SME, AEK_SMEF16F16},
- {AEK_SME, AEK_SMEF64F64},
- {AEK_SME, AEK_SMEI16I64},
- {AEK_SME, AEK_SMEFA64},
- {AEK_SME2, AEK_SME2P1},
- {AEK_SME2, AEK_SSVE_FP8FMA},
- {AEK_SME2, AEK_SSVE_FP8DOT2},
- {AEK_SME2, AEK_SSVE_FP8DOT4},
- {AEK_SME2, AEK_SMEF8F16},
- {AEK_SME2, AEK_SMEF8F32},
- {AEK_FP8, AEK_SMEF8F16},
- {AEK_FP8, AEK_SMEF8F32},
- {AEK_LSE, AEK_LSE128},
- {AEK_PREDRES, AEK_SPECRES2},
- {AEK_RAS, AEK_RASV2},
- {AEK_RCPC, AEK_RCPC3},
-};
-// clang-format on
+#define EMIT_EXTENSION_DEPENDENCIES
+#include "llvm/TargetParser/AArch64TargetParserDef.inc"
enum ArchProfile { AProfile = 'A', RProfile = 'R', InvalidProfile = '?' };
diff --git a/llvm/lib/TargetParser/AArch64TargetParser.cpp b/llvm/lib/TargetParser/AArch64TargetParser.cpp
index c10b4be4eded9..07c87415a8ec5 100644
--- a/llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -166,6 +166,12 @@ void AArch64::ExtensionSet::enable(ArchExtKind E) {
Touched.set(E);
Enabled.set(E);
+ // FIXME: Tablegen has the Subtarget Feature FeatureRCPC_IMMO which is implied
+ // by FeatureRCPC3 and in turn implies FeatureRCPC. The proper fix is to make
+ // FeatureRCPC_IMMO an Extension but that will expose it to the command line.
+ if (E == AEK_RCPC3)
+ enable(AEK_RCPC);
+
// 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.
@@ -181,12 +187,6 @@ void AArch64::ExtensionSet::enable(ArchExtKind E) {
!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);
@@ -213,6 +213,12 @@ void AArch64::ExtensionSet::disable(ArchExtKind E) {
Touched.set(E);
Enabled.reset(E);
+ // FIXME: Tablegen has the Subtarget Feature FeatureRCPC_IMMO which is implied
+ // by FeatureRCPC3 and in turn implies FeatureRCPC. The proper fix is to make
+ // FeatureRCPC_IMMO an Extension but that will expose it to the command line.
+ if (E == AEK_RCPC)
+ disable(AEK_RCPC3);
+
// Recursively disable all features that depends on this one.
for (auto Dep : ExtensionDependencies)
if (E == Dep.Earlier)
diff --git a/llvm/utils/TableGen/ARMTargetDefEmitter.cpp b/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
index b79458529623f..2c757f547b5e6 100644
--- a/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
+++ b/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
@@ -116,6 +116,20 @@ static void EmitARMTargetDef(RecordKeeper &RK, raw_ostream &OS) {
<< "#endif // EMIT_EXTENSIONS\n"
<< "\n";
+ // Emit extension dependencies
+ OS << "#ifdef EMIT_EXTENSION_DEPENDENCIES\n"
+ << "inline constexpr ExtensionDependency ExtensionDependencies[] = {\n";
+ for (const Record *Rec : SortedExtensions) {
+ auto LaterAEK = Rec->getValueAsString("ArchExtKindSpelling").upper();
+ for (auto *I : Rec->getValueAsListOfDefs("Implies"))
+ if (auto EarlierAEK = I->getValueAsOptionalString("ArchExtKindSpelling"))
+ OS << " {" << EarlierAEK->upper() << ", " << LaterAEK << "},\n";
+ }
+ OS << "};\n"
+ << "#undef EMIT_EXTENSION_DEPENDENCIES\n"
+ << "#endif // EMIT_EXTENSION_DEPENDENCIES\n"
+ << "\n";
+
// Emit architecture information
OS << "#ifdef EMIT_ARCHITECTURES\n";
More information about the llvm-commits
mailing list