Skip to content

Commit e8e5ba0

Browse files
authored
[AArch64][TargetParser] Move ExtensionDependencies into tablegen [NFC] (#93614)
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.
1 parent fbe98da commit e8e5ba0

File tree

3 files changed

+20
-55
lines changed

3 files changed

+20
-55
lines changed

llvm/include/llvm/TargetParser/AArch64TargetParser.h

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -183,55 +183,8 @@ struct ExtensionDependency {
183183
ArchExtKind Later;
184184
};
185185

186-
// clang-format off
187-
// Each entry here is a link in the dependency chain starting from the
188-
// extension that was added to the architecture first.
189-
inline constexpr ExtensionDependency ExtensionDependencies[] = {
190-
{AEK_FP, AEK_FP16},
191-
{AEK_FP, AEK_SIMD},
192-
{AEK_FP, AEK_JSCVT},
193-
{AEK_FP, AEK_FP8},
194-
{AEK_SIMD, AEK_CRYPTO},
195-
{AEK_SIMD, AEK_AES},
196-
{AEK_SIMD, AEK_SHA2},
197-
{AEK_SIMD, AEK_SHA3},
198-
{AEK_SIMD, AEK_SM4},
199-
{AEK_SIMD, AEK_RDM},
200-
{AEK_SIMD, AEK_DOTPROD},
201-
{AEK_SIMD, AEK_FCMA},
202-
{AEK_FP16, AEK_FP16FML},
203-
{AEK_FP16, AEK_SVE},
204-
{AEK_BF16, AEK_SME},
205-
{AEK_BF16, AEK_B16B16},
206-
{AEK_SVE, AEK_SVE2},
207-
{AEK_SVE, AEK_F32MM},
208-
{AEK_SVE, AEK_F64MM},
209-
{AEK_SVE2, AEK_SVE2P1},
210-
{AEK_SVE2, AEK_SVE2BITPERM},
211-
{AEK_SVE2, AEK_SVE2AES},
212-
{AEK_SVE2, AEK_SVE2SHA3},
213-
{AEK_SVE2, AEK_SVE2SM4},
214-
{AEK_SVE2, AEK_SMEFA64},
215-
{AEK_SVE2, AEK_SMEFA64},
216-
{AEK_SME, AEK_SME2},
217-
{AEK_SME, AEK_SMEF16F16},
218-
{AEK_SME, AEK_SMEF64F64},
219-
{AEK_SME, AEK_SMEI16I64},
220-
{AEK_SME, AEK_SMEFA64},
221-
{AEK_SME2, AEK_SME2P1},
222-
{AEK_SME2, AEK_SSVE_FP8FMA},
223-
{AEK_SME2, AEK_SSVE_FP8DOT2},
224-
{AEK_SME2, AEK_SSVE_FP8DOT4},
225-
{AEK_SME2, AEK_SMEF8F16},
226-
{AEK_SME2, AEK_SMEF8F32},
227-
{AEK_FP8, AEK_SMEF8F16},
228-
{AEK_FP8, AEK_SMEF8F32},
229-
{AEK_LSE, AEK_LSE128},
230-
{AEK_PREDRES, AEK_SPECRES2},
231-
{AEK_RAS, AEK_RASV2},
232-
{AEK_RCPC, AEK_RCPC3},
233-
};
234-
// clang-format on
186+
#define EMIT_EXTENSION_DEPENDENCIES
187+
#include "llvm/TargetParser/AArch64TargetParserDef.inc"
235188

236189
enum ArchProfile { AProfile = 'A', RProfile = 'R', InvalidProfile = '?' };
237190

llvm/lib/TargetParser/AArch64TargetParser.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@ void AArch64::ExtensionSet::enable(ArchExtKind E) {
181181
!BaseArch->is_superset(ARMV9A))
182182
enable(AEK_FP16FML);
183183

184-
// For all architectures, +crypto enables +aes and +sha2.
185-
if (E == AEK_CRYPTO) {
186-
enable(AEK_AES);
187-
enable(AEK_SHA2);
188-
}
189-
190184
// For v8.4A+ and v9.0A+, +crypto also enables +sha3 and +sm4.
191185
if (E == AEK_CRYPTO && BaseArch->is_superset(ARMV8_4A)) {
192186
enable(AEK_SHA3);

llvm/utils/TableGen/ARMTargetDefEmitter.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ static void EmitARMTargetDef(RecordKeeper &RK, raw_ostream &OS) {
116116
<< "#endif // EMIT_EXTENSIONS\n"
117117
<< "\n";
118118

119+
// Emit extension dependencies
120+
OS << "#ifdef EMIT_EXTENSION_DEPENDENCIES\n"
121+
<< "inline constexpr ExtensionDependency ExtensionDependencies[] = {\n";
122+
for (const Record *Rec : SortedExtensions) {
123+
auto LaterAEK = Rec->getValueAsString("ArchExtKindSpelling").upper();
124+
for (const Record *I : Rec->getValueAsListOfDefs("Implies"))
125+
if (auto EarlierAEK = I->getValueAsOptionalString("ArchExtKindSpelling"))
126+
OS << " {" << EarlierAEK->upper() << ", " << LaterAEK << "},\n";
127+
}
128+
// FIXME: Tablegen has the Subtarget Feature FeatureRCPC_IMMO which is implied
129+
// by FeatureRCPC3 and in turn implies FeatureRCPC. The proper fix is to make
130+
// FeatureRCPC_IMMO an Extension but that will expose it to the command line.
131+
OS << " {AEK_RCPC, AEK_RCPC3},\n";
132+
OS << "};\n"
133+
<< "#undef EMIT_EXTENSION_DEPENDENCIES\n"
134+
<< "#endif // EMIT_EXTENSION_DEPENDENCIES\n"
135+
<< "\n";
136+
119137
// Emit architecture information
120138
OS << "#ifdef EMIT_ARCHITECTURES\n";
121139

0 commit comments

Comments
 (0)