xref: /llvm-project/llvm/lib/Target/AArch64/AArch64Features.td (revision ef54e0bbfbef59932a59a1640f1f9e14b70cc41b)
1//=- AArch64Features.td - Describe AArch64 SubtargetFeatures -*- tablegen -*-=//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9//
10//===----------------------------------------------------------------------===//
11
12// A SubtargetFeature that represents one or more Architecture Extensions, as
13// defined by the Arm ARM and typically identified by a 'FEAT_*' name.
14// Each Extension record defines an ExtensionInfo entry in the Target Parser
15// with a corresponding 'AEK_*' entry in the ArchExtKind enum.
16class Extension<
17  string TargetFeatureName,            // String used for -target-feature, unless overridden.
18  string Spelling,                     // The XYZ in HasXYZ and AEK_XYZ.
19  string ArchitectureFeatureName,      // The extension's "FEAT_*"" name(s) defined by the architecture
20  string Desc,                         // Description.
21  list<SubtargetFeature> Implies = []  // List of dependent features.
22> : SubtargetFeature<TargetFeatureName, "Has" # Spelling, "true", Desc, Implies>
23{
24    string ArchExtKindSpelling = "AEK_" # Spelling; // ArchExtKind enum name.
25
26    string ArchFeatureName = ArchitectureFeatureName;
27
28    // The user visible name used by -march/-mcpu modifiers and target attribute
29    // values. Extensions are not available on these by default.
30    string UserVisibleName = "";
31
32    // An alias that can be used on the command line, if the extension has one.
33    // Used for correcting historical names while remaining backwards compatible.
34    string UserVisibleAlias = "";
35}
36
37// An Extension that can be toggled via a '-march'/'-mcpu' modifier or a target
38// attribute, e.g. '+sm4".
39class ExtensionWithMArch<
40  string TargetFeatureName,            // String used for -target-feature and -march, unless overridden.
41  string Spelling,                     // The XYZ in HasXYZ and AEK_XYZ.
42  string ArchitectureFeatureName,      // The extension's "FEAT_*"" name(s) defined by the architecture
43  string Desc,                         // Description.
44  list<SubtargetFeature> Implies = []  // List of dependent features.
45> : Extension<TargetFeatureName, Spelling, ArchitectureFeatureName, Desc, Implies> {
46    // In general, the name written on the command line should match the name
47    // used for -target-feature. However, there are exceptions. Therefore we
48    // add a separate field for this, to allow overriding it. Strongly prefer
49    // not doing so.
50    let UserVisibleName = TargetFeatureName;
51}
52
53
54
55// Each SubtargetFeature which corresponds to an Arm Architecture feature should
56// be annotated with the respective FEAT_ feature name from the Architecture
57// Reference Manual. If a SubtargetFeature enables instructions from multiple
58// Arm Architecture Features, it should list all the relevant features. Not all
59// FEAT_ features have a corresponding SubtargetFeature.
60
61
62//===----------------------------------------------------------------------===//
63//  Armv8.0 Architecture Extensions
64//===----------------------------------------------------------------------===//
65
66let ArchExtKindSpelling = "AEK_FP", UserVisibleName = "fp" in
67def FeatureFPARMv8 : ExtensionWithMArch<"fp-armv8", "FPARMv8", "FEAT_FP",
68  "Enable Armv8.0-A Floating Point Extensions">;
69
70let ArchExtKindSpelling = "AEK_SIMD", UserVisibleName = "simd" in
71def FeatureNEON : ExtensionWithMArch<"neon", "NEON", "FEAT_AdvSIMD",
72  "Enable Advanced SIMD instructions", [FeatureFPARMv8]>;
73
74def FeatureSHA2 : ExtensionWithMArch<"sha2", "SHA2", "FEAT_SHA1, FEAT_SHA256",
75  "Enable SHA1 and SHA256 support", [FeatureNEON]>;
76
77def FeatureAES : ExtensionWithMArch<"aes", "AES", "FEAT_AES, FEAT_PMULL",
78  "Enable AES support", [FeatureNEON]>;
79
80// Crypto has been split up and any combination is now valid (see the
81// crypto definitions above). Also, crypto is now context sensitive:
82// it has a different meaning for e.g. Armv8.4 than it has for Armv8.2.
83// Therefore, we rely on Clang, the user interfacing tool, to pass on the
84// appropriate crypto options. But here in the backend, crypto has very little
85// meaning anymore. We kept the Crypto definition here for backward
86// compatibility, and now imply features SHA2 and AES, which was the
87// "traditional" meaning of Crypto.
88def FeatureCrypto : ExtensionWithMArch<"crypto", "Crypto", "FEAT_Crypto",
89  "Enable cryptographic instructions", [FeatureNEON, FeatureSHA2, FeatureAES]>;
90
91def FeatureCRC : ExtensionWithMArch<"crc", "CRC", "FEAT_CRC32",
92  "Enable Armv8.0-A CRC-32 checksum instructions">;
93
94// This SubtargetFeature is special. It controls only whether codegen will turn
95// `llvm.readcyclecounter()` into an access to a PMUv3 System Register. The
96// `FEAT_PMUv3*` system registers are always available for assembly/disassembly.
97let UserVisibleName = "pmuv3" in
98def FeaturePerfMon : ExtensionWithMArch<"perfmon", "PerfMon", "FEAT_PMUv3",
99  "Enable Armv8.0-A PMUv3 Performance Monitors extension">;
100
101def FeatureSpecRestrict : Extension<"specrestrict", "SpecRestrict", "FEAT_CSV2_2",
102  "Enable architectural speculation restriction">;
103
104//===----------------------------------------------------------------------===//
105//  Armv8.1 Architecture Extensions
106//===----------------------------------------------------------------------===//
107
108def FeatureLSE : ExtensionWithMArch<"lse", "LSE", "FEAT_LSE",
109  "Enable Armv8.1-A Large System Extension (LSE) atomic instructions">;
110
111let UserVisibleAlias = "rdma" in
112def FeatureRDM : ExtensionWithMArch<"rdm", "RDM", "FEAT_RDM",
113  "Enable Armv8.1-A Rounding Double Multiply Add/Subtract instructions",
114  [FeatureNEON]>;
115
116def FeaturePAN : Extension<"pan", "PAN", "FEAT_PAN",
117  "Enable Armv8.1-A Privileged Access-Never extension">;
118
119def FeatureLOR : Extension<"lor", "LOR", "FEAT_LOR",
120  "Enable Armv8.1-A Limited Ordering Regions extension">;
121
122def FeatureCONTEXTIDREL2 : SubtargetFeature<"CONTEXTIDREL2", "HasCONTEXTIDREL2",
123  "true", "Enable RW operand CONTEXTIDR_EL2">;
124
125def FeatureVH : Extension<"vh", "VH", "FEAT_VHE",
126  "Enable Armv8.1-A Virtual Host extension", [FeatureCONTEXTIDREL2]>;
127
128//===----------------------------------------------------------------------===//
129//  Armv8.2 Architecture Extensions
130//===----------------------------------------------------------------------===//
131
132def FeatureSM4 : ExtensionWithMArch<"sm4", "SM4", "FEAT_SM4, FEAT_SM3",
133  "Enable SM3 and SM4 support", [FeatureNEON]>;
134
135def FeatureSHA3 : ExtensionWithMArch<"sha3", "SHA3", "FEAT_SHA3, FEAT_SHA512",
136  "Enable SHA512 and SHA3 support", [FeatureNEON, FeatureSHA2]>;
137
138def FeatureRAS : ExtensionWithMArch<"ras", "RAS", "FEAT_RAS, FEAT_RASv1p1",
139  "Enable Armv8.0-A Reliability, Availability and Serviceability Extensions">;
140
141let ArchExtKindSpelling = "AEK_FP16", UserVisibleName = "fp16" in
142def FeatureFullFP16 : ExtensionWithMArch<"fullfp16", "FullFP16", "FEAT_FP16",
143  "Enable half-precision floating-point data processing", [FeatureFPARMv8]>;
144
145let ArchExtKindSpelling = "AEK_PROFILE", UserVisibleName = "profile" in
146def FeatureSPE : ExtensionWithMArch<"spe", "SPE", "FEAT_SPE",
147  "Enable Statistical Profiling extension">;
148
149def FeaturePAN_RWV : Extension<"pan-rwv", "PAN_RWV", "FEAT_PAN2",
150  "Enable Armv8.2-A PAN s1e1R and s1e1W Variants", [FeaturePAN]>;
151
152def FeaturePsUAO : Extension<"uaops", "PsUAO", "FEAT_UAO",
153  "Enable Armv8.2-A UAO PState">;
154
155def FeatureCCPP : Extension<"ccpp", "CCPP", "FEAT_DPB",
156  "Enable Armv8.2-A data Cache Clean to Point of Persistence">;
157
158def FeatureSVE : ExtensionWithMArch<"sve", "SVE", "FEAT_SVE",
159  "Enable Scalable Vector Extension (SVE) instructions", [FeatureFullFP16]>;
160
161let ArchExtKindSpelling = "AEK_I8MM" in
162def FeatureMatMulInt8 : ExtensionWithMArch<"i8mm", "MatMulInt8", "FEAT_I8MM",
163  "Enable Matrix Multiply Int8 Extension", [FeatureNEON]>;
164
165let ArchExtKindSpelling = "AEK_F32MM" in
166def FeatureMatMulFP32 : ExtensionWithMArch<"f32mm", "MatMulFP32", "FEAT_F32MM",
167  "Enable Matrix Multiply FP32 Extension", [FeatureSVE]>;
168
169let ArchExtKindSpelling = "AEK_F64MM" in
170def FeatureMatMulFP64 : ExtensionWithMArch<"f64mm", "MatMulFP64", "FEAT_F64MM",
171  "Enable Matrix Multiply FP64 Extension", [FeatureSVE]>;
172
173//===----------------------------------------------------------------------===//
174//  Armv8.3 Architecture Extensions
175//===----------------------------------------------------------------------===//
176
177def FeatureRCPC : ExtensionWithMArch<"rcpc", "RCPC", "FEAT_LRCPC",
178  "Enable support for RCPC extension">;
179
180def FeaturePAuth : ExtensionWithMArch<"pauth", "PAuth", "FEAT_PAuth",
181  "Enable Armv8.3-A Pointer Authentication extension">;
182
183let ArchExtKindSpelling = "AEK_JSCVT", UserVisibleName = "jscvt" in
184def FeatureJS : ExtensionWithMArch<"jsconv", "JS", "FEAT_JSCVT",
185  "Enable Armv8.3-A JavaScript FP conversion instructions",
186  [FeatureFPARMv8]>;
187
188def FeatureFPAC : Extension<"fpac", "FPAC", "FEAT_FPAC",
189  "Enable Armv8.3-A Pointer Authentication Faulting enhancement">;
190
191def FeatureCCIDX : Extension<"ccidx", "CCIDX", "FEAT_CCIDX",
192  "Enable Armv8.3-A Extend of the CCSIDR number of sets">;
193
194let ArchExtKindSpelling = "AEK_FCMA", UserVisibleName = "fcma" in
195def FeatureComplxNum : ExtensionWithMArch<"complxnum", "ComplxNum", "FEAT_FCMA",
196  "Enable Armv8.3-A Floating-point complex number support",
197  [FeatureNEON]>;
198
199def FeatureNV : Extension<"nv", "NV", "FEAT_NV, FEAT_NV2",
200  "Enable Armv8.4-A Nested Virtualization Enchancement">;
201
202//===----------------------------------------------------------------------===//
203//  Armv8.4 Architecture Extensions
204//===----------------------------------------------------------------------===//
205
206def FeatureLSE2 : Extension<"lse2", "LSE2", "FEAT_LSE2",
207  "Enable Armv8.4-A Large System Extension 2 (LSE2) atomicity rules">;
208
209def FeatureFP16FML : ExtensionWithMArch<"fp16fml", "FP16FML", "FEAT_FHM",
210  "Enable FP16 FML instructions", [FeatureFullFP16, FeatureNEON]>;
211
212def FeatureDotProd : ExtensionWithMArch<"dotprod", "DotProd", "FEAT_DotProd",
213  "Enable dot product support", [FeatureNEON]>;
214
215def FeatureMPAM : Extension<"mpam", "MPAM", "FEAT_MPAM",
216  "Enable Armv8.4-A Memory system Partitioning and Monitoring extension">;
217
218def FeatureDIT : ExtensionWithMArch<"dit", "DIT", "FEAT_DIT",
219  "Enable Armv8.4-A Data Independent Timing instructions">;
220
221def FeatureTRACEV8_4 : Extension<"tracev8.4", "TRACEV8_4", "FEAT_TRF",
222  "Enable Armv8.4-A Trace extension">;
223
224def FeatureAM : Extension<"am", "AM", "FEAT_AMUv1",
225  "Enable Armv8.4-A Activity Monitors extension">;
226
227def FeatureSEL2 : Extension<"sel2", "SEL2", "FEAT_SEL2",
228  "Enable Armv8.4-A Secure Exception Level 2 extension">;
229
230def FeatureTLB_RMI : Extension<"tlb-rmi", "TLB_RMI",
231  "FEAT_TLBIOS, FEAT_TLBIRANGE",
232  "Enable Armv8.4-A TLB Range and Maintenance instructions">;
233
234def FeatureFlagM : ExtensionWithMArch<"flagm", "FlagM", "FEAT_FlagM",
235  "Enable Armv8.4-A Flag Manipulation instructions">;
236
237def FeatureRCPC_IMMO : Extension<"rcpc-immo", "RCPC_IMMO", "FEAT_LRCPC2",
238  "Enable Armv8.4-A RCPC instructions with Immediate Offsets",
239  [FeatureRCPC]>;
240
241//===----------------------------------------------------------------------===//
242//  Armv8.5 Architecture Extensions
243//===----------------------------------------------------------------------===//
244
245def FeatureAltFPCmp : Extension<"altnzcv", "AlternativeNZCV", "FEAT_FlagM2",
246  "Enable alternative NZCV format for floating point comparisons", [FeatureFlagM]>;
247
248def FeatureFRInt3264 : Extension<"fptoint", "FRInt3264", "FEAT_FRINTTS",
249  "Enable FRInt[32|64][Z|X] instructions that round a floating-point number to "
250  "an integer (in FP format) forcing it to fit into a 32- or 64-bit int",
251  [FeatureFPARMv8]>;
252
253def FeatureSB : ExtensionWithMArch<"sb", "SB", "FEAT_SB",
254  "Enable Armv8.5-A Speculation Barrier">;
255
256def FeatureSSBS : ExtensionWithMArch<"ssbs", "SSBS", "FEAT_SSBS, FEAT_SSBS2",
257  "Enable Speculative Store Bypass Safe bit">;
258
259def FeaturePredRes : ExtensionWithMArch<"predres", "PredRes", "FEAT_SPECRES",
260  "Enable Armv8.5-A execution and data prediction invalidation instructions">;
261
262def FeatureCacheDeepPersist : Extension<"ccdp", "CCDP", "FEAT_DPB2",
263  "Enable Armv8.5-A Cache Clean to Point of Deep Persistence", [FeatureCCPP]>;
264
265def FeatureBranchTargetId : ExtensionWithMArch<"bti", "BTI", "FEAT_BTI",
266  "Enable Branch Target Identification">;
267
268let ArchExtKindSpelling = "AEK_RAND", UserVisibleName = "rng" in
269def FeatureRandGen : ExtensionWithMArch<"rand", "RandGen", "FEAT_RNG",
270  "Enable Random Number generation instructions">;
271
272// NOTE: "memtag" means FEAT_MTE + FEAT_MTE2 for -march or
273// __attribute((target(...))), but only FEAT_MTE for FMV.
274let UserVisibleName = "memtag" in
275def FeatureMTE : ExtensionWithMArch<"mte", "MTE", "FEAT_MTE, FEAT_MTE2",
276  "Enable Memory Tagging Extension">;
277
278//===----------------------------------------------------------------------===//
279//  Armv8.6 Architecture Extensions
280//===----------------------------------------------------------------------===//
281
282def FeatureBF16 : ExtensionWithMArch<"bf16", "BF16", "FEAT_BF16",
283  "Enable BFloat16 Extension", [FeatureNEON]>;
284
285def FeatureAMVS : Extension<"amvs", "AMVS", "FEAT_AMUv1p1",
286  "Enable Armv8.6-A Activity Monitors Virtualization support",
287  [FeatureAM]>;
288
289def FeatureFineGrainedTraps : Extension<"fgt", "FineGrainedTraps", "FEAT_FGT",
290  "Enable fine grained virtualization traps extension">;
291
292def FeatureEnhancedCounterVirtualization :
293    Extension<"ecv", "EnhancedCounterVirtualization", "FEAT_ECV",
294      "Enable enhanced counter virtualization extension">;
295
296//===----------------------------------------------------------------------===//
297//  Armv8.7 Architecture Extensions
298//===----------------------------------------------------------------------===//
299
300def FeatureXS : Extension<"xs", "XS", "FEAT_XS",
301  "Enable Armv8.7-A limited-TLB-maintenance instruction">;
302
303def FeatureWFxT : ExtensionWithMArch<"wfxt", "WFxT", "FEAT_WFxT",
304  "Enable Armv8.7-A WFET and WFIT instruction">;
305
306def FeatureHCX : Extension<"hcx", "HCX", "FEAT_HCX",
307  "Enable Armv8.7-A HCRX_EL2 system register">;
308
309def FeatureLS64 : ExtensionWithMArch<"ls64", "LS64",
310  "FEAT_LS64, FEAT_LS64_V, FEAT_LS64_ACCDATA",
311  "Enable Armv8.7-A LD64B/ST64B Accelerator Extension">;
312
313def FeatureSPE_EEF : Extension<"spe-eef", "SPE_EEF", "FEAT_SPEv1p2",
314  "Enable extra register in the Statistical Profiling Extension">;
315
316//===----------------------------------------------------------------------===//
317//  Armv8.8 Architecture Extensions
318//===----------------------------------------------------------------------===//
319
320def FeatureHBC : ExtensionWithMArch<"hbc", "HBC", "FEAT_HBC",
321    "Enable Armv8.8-A Hinted Conditional Branches Extension">;
322
323def FeatureMOPS : ExtensionWithMArch<"mops", "MOPS", "FEAT_MOPS",
324    "Enable Armv8.8-A memcpy and memset acceleration instructions">;
325
326def FeatureNMI : Extension<"nmi", "NMI", "FEAT_NMI, FEAT_GICv3_NMI",
327  "Enable Armv8.8-A Non-maskable Interrupts">;
328
329//===----------------------------------------------------------------------===//
330//  Armv8.9 Architecture Extensions
331//===----------------------------------------------------------------------===//
332
333def FeatureRASv2 : ExtensionWithMArch<"rasv2", "RASv2", "FEAT_RASv2",
334  "Enable Armv8.9-A Reliability, Availability and Serviceability Extensions",
335  [FeatureRAS]>;
336
337def FeatureCSSC : ExtensionWithMArch<"cssc", "CSSC", "FEAT_CSSC",
338  "Enable Common Short Sequence Compression (CSSC) instructions">;
339
340def FeatureCLRBHB : Extension<"clrbhb", "CLRBHB", "FEAT_CLRBHB",
341  "Enable Clear BHB instruction">;
342
343def FeaturePRFM_SLC : Extension<"prfm-slc-target", "PRFM_SLC", "FEAT_PRFMSLC",
344  "Enable SLC target for PRFM instruction">;
345
346let UserVisibleName = "predres2" in
347def FeatureSPECRES2 : ExtensionWithMArch<"specres2", "SPECRES2", "FEAT_SPECRES2",
348  "Enable Speculation Restriction Instruction",
349  [FeaturePredRes]>;
350
351def FeatureRCPC3 : ExtensionWithMArch<"rcpc3", "RCPC3", "FEAT_LRCPC3",
352  "Enable Armv8.9-A RCPC instructions for A64 and Advanced SIMD and floating-point instruction set",
353  [FeatureRCPC_IMMO]>;
354
355def FeatureTHE : ExtensionWithMArch<"the", "THE", "FEAT_THE",
356  "Enable Armv8.9-A Translation Hardening Extension">;
357
358//===----------------------------------------------------------------------===//
359//  Armv9.0 Architecture Extensions
360//===----------------------------------------------------------------------===//
361
362def FeatureSVE2 : ExtensionWithMArch<"sve2", "SVE2", "FEAT_SVE2",
363  "Enable Scalable Vector Extension 2 (SVE2) instructions",
364  [FeatureSVE]>;
365
366def FeatureSVEAES : ExtensionWithMArch<"sve-aes", "SVEAES",
367  "FEAT_SVE_AES, FEAT_SVE_PMULL128",
368  "Enable SVE AES and quadword SVE polynomial multiply instructions", [FeatureAES]>;
369
370def FeatureAliasSVE2AES : ExtensionWithMArch<"sve2-aes", "SVE2AES",
371  "", "Shorthand for +sve2+sve-aes", [FeatureSVE2, FeatureSVEAES]>;
372
373def FeatureSVE2SM4 : ExtensionWithMArch<"sve2-sm4", "SVE2SM4", "FEAT_SVE_SM4",
374  "Enable SM4 SVE2 instructions", [FeatureSVE2, FeatureSM4]>;
375
376def FeatureSVE2SHA3 : ExtensionWithMArch<"sve2-sha3", "SVE2SHA3", "FEAT_SVE_SHA3",
377  "Enable SHA3 SVE2 instructions", [FeatureSVE2, FeatureSHA3]>;
378
379def FeatureSVEBitPerm : ExtensionWithMArch<"sve-bitperm", "SVEBitPerm",
380  "FEAT_SVE_BitPerm",  "Enable bit permutation SVE2 instructions">;
381
382def FeatureAliasSVE2BitPerm : ExtensionWithMArch<"sve2-bitperm", "SVE2BitPerm",
383  "",  "Shorthand for +sve2+sve-bitperm", [FeatureSVE2, FeatureSVEBitPerm]>;
384
385def FeatureTRBE : Extension<"trbe", "TRBE", "FEAT_TRBE",
386  "Enable Trace Buffer Extension">;
387
388def FeatureETE : Extension<"ete", "ETE", "FEAT_ETE",
389  "Enable Embedded Trace Extension", [FeatureTRBE]>;
390
391def FeatureTME : ExtensionWithMArch<"tme", "TME", "FEAT_TME",
392  "Enable Transactional Memory Extension">;
393
394//===----------------------------------------------------------------------===//
395//  Armv9.1 Architecture Extensions
396//===----------------------------------------------------------------------===//
397
398//===----------------------------------------------------------------------===//
399//  Armv9.2 Architecture Extensions
400//===----------------------------------------------------------------------===//
401
402def FeatureBRBE : ExtensionWithMArch<"brbe", "BRBE", "FEAT_BRBE",
403  "Enable Branch Record Buffer Extension">;
404
405def FeatureRME : Extension<"rme", "RME", "FEAT_RME",
406  "Enable Realm Management Extension">;
407
408def FeatureSME : ExtensionWithMArch<"sme", "SME", "FEAT_SME",
409  "Enable Scalable Matrix Extension (SME)", [FeatureBF16, FeatureFullFP16]>;
410
411def FeatureSMEF64F64 : ExtensionWithMArch<"sme-f64f64", "SMEF64F64", "FEAT_SME_F64F64",
412  "Enable Scalable Matrix Extension (SME) F64F64 instructions", [FeatureSME]>;
413
414def FeatureSMEI16I64 : ExtensionWithMArch<"sme-i16i64", "SMEI16I64", "FEAT_SME_I16I64",
415  "Enable Scalable Matrix Extension (SME) I16I64 instructions", [FeatureSME]>;
416
417def FeatureSMEFA64 : ExtensionWithMArch<"sme-fa64", "SMEFA64", "FEAT_SME_FA64",
418  "Enable the full A64 instruction set in streaming SVE mode", [FeatureSME, FeatureSVE2]>;
419
420//===----------------------------------------------------------------------===//
421//  Armv9.3 Architecture Extensions
422//===----------------------------------------------------------------------===//
423
424def FeatureSME2 : ExtensionWithMArch<"sme2", "SME2", "FEAT_SME2",
425  "Enable Scalable Matrix Extension 2 (SME2) instructions", [FeatureSME]>;
426
427def FeatureMEC : Extension<"mec", "MEC", "FEAT_MEC",
428  "Enable Memory Encryption Contexts Extension", [FeatureRME]>;
429
430//===----------------------------------------------------------------------===//
431//  Armv9.4 Architecture Extensions
432//===----------------------------------------------------------------------===//
433
434def FeatureSVE2p1: ExtensionWithMArch<"sve2p1", "SVE2p1", "FEAT_SVE2p1",
435  "Enable Scalable Vector Extension 2.1 instructions", [FeatureSVE2]>;
436
437def FeatureSVEB16B16: ExtensionWithMArch<"sve-b16b16", "SVEB16B16", "FEAT_SVE_B16B16",
438  "Enable SVE2 non-widening and SME2 Z-targeting non-widening BFloat16 instructions">;
439
440def FeatureSMEB16B16 : ExtensionWithMArch<"sme-b16b16", "SMEB16B16", "FEAT_SME_B16B16",
441  "Enable SME2.1 ZA-targeting non-widening BFloat16 instructions",
442  [FeatureSME2, FeatureSVEB16B16]>;
443
444def FeatureSMEF16F16 : ExtensionWithMArch<"sme-f16f16", "SMEF16F16", "FEAT_SME_F16F16",
445  "Enable SME non-widening Float16 instructions", [FeatureSME2]>;
446
447def FeatureSME2p1 : ExtensionWithMArch<"sme2p1", "SME2p1", "FEAT_SME2p1",
448  "Enable Scalable Matrix Extension 2.1 instructions", [FeatureSME2]>;
449
450def FeatureCHK : Extension<"chk", "CHK", "FEAT_CHK",
451  "Enable Armv8.0-A Check Feature Status Extension">;
452
453def FeatureGCS : ExtensionWithMArch<"gcs", "GCS", "FEAT_GCS",
454  "Enable Armv9.4-A Guarded Call Stack Extension", [FeatureCHK]>;
455
456def FeatureITE : ExtensionWithMArch<"ite", "ITE", "FEAT_ITE",
457  "Enable Armv9.4-A Instrumentation Extension", [FeatureETE, FeatureTRBE]>;
458
459def FeatureLSE128 : ExtensionWithMArch<"lse128", "LSE128", "FEAT_LSE128",
460  "Enable Armv9.4-A 128-bit Atomic instructions",
461  [FeatureLSE]>;
462
463// FEAT_D128, FEAT_LVA3, FEAT_SYSREG128, and FEAT_SYSINSTR128 are mutually implicit.
464// Therefore group them all under a single feature flag, d128:
465def FeatureD128 : ExtensionWithMArch<"d128", "D128",
466  "FEAT_D128, FEAT_LVA3, FEAT_SYSREG128, FEAT_SYSINSTR128",
467  "Enable Armv9.4-A 128-bit Page Table Descriptors, System Registers "
468  "and instructions",
469  [FeatureLSE128]>;
470
471//===----------------------------------------------------------------------===//
472//  Armv9.5 Architecture Extensions
473//===----------------------------------------------------------------------===//
474
475def FeatureFAMINMAX: ExtensionWithMArch<"faminmax", "FAMINMAX", "FEAT_FAMINMAX",
476 "Enable FAMIN and FAMAX instructions">;
477
478def FeatureLUT: ExtensionWithMArch<"lut", "LUT", "FEAT_LUT",
479 "Enable Lookup Table instructions">;
480
481def FeatureFP8 : ExtensionWithMArch<"fp8", "FP8", "FEAT_FP8",
482  "Enable FP8 instructions", [FeatureFAMINMAX, FeatureLUT, FeatureBF16]>;
483
484def FeatureFP8FMA : ExtensionWithMArch<"fp8fma", "FP8FMA", "FEAT_FP8FMA",
485  "Enable Armv9.5-A FP8 multiply-add instructions", [FeatureFP8]>;
486
487def FeatureSSVE_FP8FMA : ExtensionWithMArch<"ssve-fp8fma", "SSVE_FP8FMA", "FEAT_SSVE_FP8FMA",
488  "Enable SVE2 FP8 multiply-add instructions", [FeatureSME2, FeatureFP8]>;
489
490def FeatureFP8DOT4: ExtensionWithMArch<"fp8dot4", "FP8DOT4", "FEAT_FP8DOT4",
491  "Enable FP8 4-way dot instructions", [FeatureNEON, FeatureFP8]>;
492
493def FeatureFP8DOT2: ExtensionWithMArch<"fp8dot2", "FP8DOT2", "FEAT_FP8DOT2",
494  "Enable FP8 2-way dot instructions", [FeatureNEON, FeatureFP8]>;
495
496def FeatureSSVE_FP8DOT4 : ExtensionWithMArch<"ssve-fp8dot4", "SSVE_FP8DOT4", "FEAT_SSVE_FP8DOT4",
497  "Enable SVE2 FP8 4-way dot product instructions", [FeatureSME2, FeatureFP8]>;
498
499def FeatureSSVE_FP8DOT2 : ExtensionWithMArch<"ssve-fp8dot2", "SSVE_FP8DOT2", "FEAT_SSVE_FP8DOT2",
500  "Enable SVE2 FP8 2-way dot product instructions", [FeatureSME2, FeatureFP8]>;
501
502def FeatureSME_LUTv2 : ExtensionWithMArch<"sme-lutv2", "SME_LUTv2", "FEAT_SME_LUTv2",
503  "Enable Scalable Matrix Extension (SME) LUTv2 instructions", [FeatureSME2]>;
504
505def FeatureSMEF8F32 : ExtensionWithMArch<"sme-f8f32", "SMEF8F32", "FEAT_SME_F8F32",
506  "Enable Scalable Matrix Extension (SME) F8F32 instructions", [FeatureSME2, FeatureFP8]>;
507
508def FeatureSMEF8F16 : ExtensionWithMArch<"sme-f8f16", "SMEF8F16", "FEAT_SME_F8F16",
509  "Enable Scalable Matrix Extension (SME) F8F16 instructions", [FeatureSME2, FeatureFP8]>;
510
511def FeatureCPA : ExtensionWithMArch<"cpa", "CPA", "FEAT_CPA",
512  "Enable Armv9.5-A Checked Pointer Arithmetic">;
513
514def FeaturePAuthLR : ExtensionWithMArch<"pauth-lr", "PAuthLR", "FEAT_PAuth_LR",
515  "Enable Armv9.5-A PAC enhancements">;
516
517def FeatureTLBIW : ExtensionWithMArch<"tlbiw", "TLBIW", "FEAT_TLBIW",
518  "Enable Armv9.5-A TLBI VMALL for Dirty State">;
519
520//===----------------------------------------------------------------------===//
521//  Armv9.6 Architecture Extensions
522//===----------------------------------------------------------------------===//
523
524def FeatureCMPBR : ExtensionWithMArch<"cmpbr", "CMPBR", "FEAT_CMPBR",
525  "Enable Armv9.6-A base compare and branch instructions">;
526
527def FeatureF8F32MM: ExtensionWithMArch<"f8f32mm", "F8F32MM", "FEAT_F8F32MM",
528  "Enable Armv9.6-A FP8 to Single-Precision Matrix Multiplication", [FeatureNEON, FeatureFP8]>;
529
530def FeatureF8F16MM: ExtensionWithMArch<"f8f16mm", "F8F16MM", "FEAT_F8F16MM",
531  "Enable Armv9.6-A FP8 to Half-Precision Matrix Multiplication", [FeatureNEON, FeatureFP8]>;
532
533def FeatureFPRCVT: ExtensionWithMArch<"fprcvt", "FPRCVT", "FEAT_FPRCVT",
534  "Enable Armv9.6-A base convert instructions for SIMD&FP scalar register operands of"
535  " different input and output sizes", [FeatureFPARMv8]>;
536
537def FeatureLSFE : ExtensionWithMArch<"lsfe", "LSFE", "FEAT_LSFE",
538  "Enable Armv9.6-A base Atomic floating-point in-memory instructions", [FeatureFPARMv8]>;
539
540def FeatureSME2p2: ExtensionWithMArch<"sme2p2", "SME2p2", "FEAT_SME2p2",
541  "Enable Armv9.6-A Scalable Matrix Extension 2.2 instructions", [FeatureSME2p1]>;
542
543def FeatureSSVE_AES : ExtensionWithMArch<"ssve-aes", "SSVE_AES", "FEAT_SSVE_AES",
544  "Enable Armv9.6-A SVE AES support in streaming SVE mode", [FeatureSME2, FeatureSVEAES]>;
545
546def FeatureSVE2p2 : ExtensionWithMArch<"sve2p2", "SVE2p2", "FEAT_SVE2p2",
547  "Enable Armv9.6-A Scalable Vector Extension 2.2 instructions", [FeatureSVE2p1]>;
548
549def FeatureSVEAES2: ExtensionWithMArch<"sve-aes2", "SVE_AES2", "FEAT_SVE_AES2",
550  "Enable Armv9.6-A SVE multi-vector AES and multi-vector quadword polynomial multiply instructions">;
551
552def FeatureSVEBFSCALE: ExtensionWithMArch<"sve-bfscale", "SVE_BFSCALE", "FEAT_SVE_BFSCALE",
553  "Enable Armv9.6-A SVE BFloat16 scaling instructions">;
554
555def FeatureSVE_F16F32MM: ExtensionWithMArch<"sve-f16f32mm", "SVE_F16F32MM", "FEAT_SVE_F16F32MM",
556  "Enable Armv9.6-A FP16 to FP32 Matrix Multiply instructions", [FeatureSVE]>;
557
558def FeatureLSUI: ExtensionWithMArch<"lsui", "LSUI", "FEAT_LSUI",
559  "Enable Armv9.6-A unprivileged load/store instructions">;
560
561def FeatureOCCMO: ExtensionWithMArch<"occmo", "OCCMO", "FEAT_OCCMO",
562  "Enable Armv9.6-A Outer cacheable cache maintenance operations">;
563
564def FeaturePCDPHINT: ExtensionWithMArch<"pcdphint", "PCDPHINT", "FEAT_PCDPHINT",
565  "Enable Armv9.6-A Producer Consumer Data Placement hints">;
566
567def FeaturePoPS: ExtensionWithMArch<"pops", "PoPS", "FEAT_PoPS",
568  "Enable Armv9.6-A Point Of Physical Storage (PoPS) DC instructions">;
569
570def FeatureSSVE_BitPerm : ExtensionWithMArch<"ssve-bitperm", "SSVE_BitPerm", "FEAT_SSVE_BitPerm",
571  "Enable Armv9.6-A SVE BitPerm support in streaming SVE mode", [FeatureSME2, FeatureSVEBitPerm]>;
572
573def FeatureSME_MOP4: ExtensionWithMArch<"sme-mop4", "SME_MOP4", "FEAT_SME_MOP4",
574  "Enable SME Quarter-tile outer product instructions", [FeatureSME2]>;
575
576def FeatureSME_TMOP: ExtensionWithMArch<"sme-tmop", "SME_TMOP", "FEAT_SME_TMOP",
577  "Enable SME Structured sparsity outer product instructions.", [FeatureSME2]>;
578
579//===----------------------------------------------------------------------===//
580//  Other Features
581//===----------------------------------------------------------------------===//
582
583def FeatureOutlineAtomics : SubtargetFeature<"outline-atomics", "OutlineAtomics", "true",
584  "Enable out of line atomics to support LSE instructions">;
585
586def FeatureFMV : SubtargetFeature<"fmv", "HasFMV", "true",
587  "Enable Function Multi Versioning support.">;
588
589// This flag is currently still labeled as Experimental, but when fully
590// implemented this should tell the compiler to use the zeroing pseudos to
591// benefit from the reverse instructions (e.g. SUB vs SUBR) if the inactive
592// lanes are known to be zero. The pseudos will then be expanded using the
593// MOVPRFX instruction to zero the inactive lanes. This feature should only be
594// enabled if MOVPRFX instructions are known to merge with the destructive
595// operations they prefix.
596//
597// This feature could similarly be extended to support cheap merging of _any_
598// value into the inactive lanes using the MOVPRFX instruction that uses
599// merging-predication.
600def FeatureExperimentalZeroingPseudos
601    : SubtargetFeature<"use-experimental-zeroing-pseudos",
602                       "UseExperimentalZeroingPseudos", "true",
603                       "Hint to the compiler that the MOVPRFX instruction is "
604                       "merged with destructive operations",
605                       []>;
606
607def FeatureNoSVEFPLD1R : SubtargetFeature<"no-sve-fp-ld1r",
608  "NoSVEFPLD1R", "true", "Avoid using LD1RX instructions for FP">;
609
610def FeatureZCRegMove : SubtargetFeature<"zcm", "HasZeroCycleRegMove", "true",
611                                        "Has zero-cycle register moves">;
612
613def FeatureZCZeroingGP : SubtargetFeature<"zcz-gp", "HasZeroCycleZeroingGP", "true",
614                                        "Has zero-cycle zeroing instructions for generic registers">;
615
616// It is generally beneficial to rewrite "fmov s0, wzr" to "movi d0, #0".
617// as movi is more efficient across all cores. Newer cores can eliminate
618// fmovs early and there is no difference with movi, but this not true for
619// all implementations.
620def FeatureNoZCZeroingFP : SubtargetFeature<"no-zcz-fp", "HasZeroCycleZeroingFP", "false",
621                                        "Has no zero-cycle zeroing instructions for FP registers">;
622
623def FeatureZCZeroing : SubtargetFeature<"zcz", "HasZeroCycleZeroing", "true",
624                                        "Has zero-cycle zeroing instructions",
625                                        [FeatureZCZeroingGP]>;
626
627/// ... but the floating-point version doesn't quite work in rare cases on older
628/// CPUs.
629def FeatureZCZeroingFPWorkaround : SubtargetFeature<"zcz-fp-workaround",
630    "HasZeroCycleZeroingFPWorkaround", "true",
631    "The zero-cycle floating-point zeroing instruction has a bug">;
632
633def FeatureStrictAlign : SubtargetFeature<"strict-align",
634                                          "RequiresStrictAlign", "true",
635                                          "Disallow all unaligned memory "
636                                          "access">;
637
638foreach i = {1-7,9-15,18,20-28} in
639    def FeatureReserveX#i : SubtargetFeature<"reserve-x"#i, "ReserveXRegister["#i#"]", "true",
640                                             "Reserve X"#i#", making it unavailable "
641                                             "as a GPR">;
642
643def FeatureReserveLRForRA : SubtargetFeature<"reserve-lr-for-ra",
644                                             "ReserveLRForRA", "true",
645                                             "Reserve LR for call use only">;
646
647foreach i = {8-15,18} in
648    def FeatureCallSavedX#i : SubtargetFeature<"call-saved-x"#i,
649         "CustomCallSavedXRegs["#i#"]", "true", "Make X"#i#" callee saved.">;
650
651def FeatureBalanceFPOps : SubtargetFeature<"balance-fp-ops", "BalanceFPOps",
652    "true",
653    "balance mix of odd and even D-registers for fp multiply(-accumulate) ops">;
654
655def FeaturePredictableSelectIsExpensive : SubtargetFeature<
656    "predictable-select-expensive", "PredictableSelectIsExpensive", "true",
657    "Prefer likely predicted branches over selects">;
658
659def FeatureEnableSelectOptimize : SubtargetFeature<
660    "enable-select-opt", "EnableSelectOptimize", "true",
661    "Enable the select optimize pass for select loop heuristics">;
662
663def FeatureExynosCheapAsMoveHandling : SubtargetFeature<"exynos-cheap-as-move",
664    "HasExynosCheapAsMoveHandling", "true",
665    "Use Exynos specific handling of cheap instructions">;
666
667def FeaturePostRAScheduler : SubtargetFeature<"use-postra-scheduler",
668    "UsePostRAScheduler", "true", "Schedule again after register allocation">;
669
670def FeatureSlowMisaligned128Store : SubtargetFeature<"slow-misaligned-128store",
671    "IsMisaligned128StoreSlow", "true", "Misaligned 128 bit stores are slow">;
672
673def FeatureSlowPaired128 : SubtargetFeature<"slow-paired-128",
674    "IsPaired128Slow", "true", "Paired 128 bit loads and stores are slow">;
675
676def FeatureAscendStoreAddress : SubtargetFeature<"ascend-store-address",
677    "IsStoreAddressAscend", "true",
678    "Schedule vector stores by ascending address">;
679
680def FeatureSlowSTRQro : SubtargetFeature<"slow-strqro-store", "IsSTRQroSlow",
681    "true", "STR of Q register with register offset is slow">;
682
683def FeatureAlternateSExtLoadCVTF32Pattern : SubtargetFeature<
684    "alternate-sextload-cvt-f32-pattern", "UseAlternateSExtLoadCVTF32Pattern",
685    "true", "Use alternative pattern for sextload convert to f32">;
686
687def FeatureArithmeticBccFusion : SubtargetFeature<
688    "arith-bcc-fusion", "HasArithmeticBccFusion", "true",
689    "CPU fuses arithmetic+bcc operations">;
690
691def FeatureArithmeticCbzFusion : SubtargetFeature<
692    "arith-cbz-fusion", "HasArithmeticCbzFusion", "true",
693    "CPU fuses arithmetic + cbz/cbnz operations">;
694
695def FeatureCmpBccFusion : SubtargetFeature<
696    "cmp-bcc-fusion", "HasCmpBccFusion", "true",
697    "CPU fuses cmp+bcc operations">;
698
699def FeatureFuseAddress : SubtargetFeature<
700    "fuse-address", "HasFuseAddress", "true",
701    "CPU fuses address generation and memory operations">;
702
703def FeatureFuseAES : SubtargetFeature<
704    "fuse-aes", "HasFuseAES", "true",
705    "CPU fuses AES crypto operations">;
706
707def FeatureFuseArithmeticLogic : SubtargetFeature<
708    "fuse-arith-logic", "HasFuseArithmeticLogic", "true",
709    "CPU fuses arithmetic and logic operations">;
710
711def FeatureFuseCCSelect : SubtargetFeature<
712    "fuse-csel", "HasFuseCCSelect", "true",
713    "CPU fuses conditional select operations">;
714
715def FeatureFuseCryptoEOR : SubtargetFeature<
716    "fuse-crypto-eor", "HasFuseCryptoEOR", "true",
717    "CPU fuses AES/PMULL and EOR operations">;
718
719def FeatureFuseAdrpAdd : SubtargetFeature<
720    "fuse-adrp-add", "HasFuseAdrpAdd", "true",
721    "CPU fuses adrp+add operations">;
722
723def FeatureFuseLiterals : SubtargetFeature<
724    "fuse-literals", "HasFuseLiterals", "true",
725    "CPU fuses literal generation operations">;
726
727def FeatureFuseAddSub2RegAndConstOne : SubtargetFeature<
728   "fuse-addsub-2reg-const1", "HasFuseAddSub2RegAndConstOne", "true",
729   "CPU fuses (a + b + 1) and (a - b - 1)">;
730
731def FeatureDisableLatencySchedHeuristic : SubtargetFeature<
732    "disable-latency-sched-heuristic", "DisableLatencySchedHeuristic", "true",
733    "Disable latency scheduling heuristic">;
734
735def FeatureStorePairSuppress : SubtargetFeature<
736    "store-pair-suppress", "EnableStorePairSuppress", "true",
737    "Enable Store Pair Suppression heuristics">;
738
739def FeatureForce32BitJumpTables
740   : SubtargetFeature<"force-32bit-jump-tables", "Force32BitJumpTables", "true",
741                      "Force jump table entries to be 32-bits wide except at MinSize">;
742
743def FeatureUseRSqrt : SubtargetFeature<
744    "use-reciprocal-square-root", "UseRSqrt", "true",
745    "Use the reciprocal square root approximation">;
746
747def FeatureNoNegativeImmediates : SubtargetFeature<"no-neg-immediates",
748                                        "NegativeImmediates", "false",
749                                        "Convert immediates and instructions "
750                                        "to their negated or complemented "
751                                        "equivalent when the immediate does "
752                                        "not fit in the encoding.">;
753
754// Address operands with shift amount 2 or 3 are fast on all Arm chips except
755// some old Apple cores (A7-A10?) which handle all shifts slowly. Cortex-A57
756// and derived designs through Cortex-X1 take an extra micro-op for shifts
757// of 1 or 4. Other Arm chips handle all shifted operands at the same speed
758// as unshifted operands.
759//
760// We don't try to model the behavior of the old Apple cores because new code
761// targeting A7 is very unlikely to actually run on an A7. The Cortex cores
762// are modeled by FeatureAddrLSLSlow14.
763def FeatureAddrLSLSlow14 : SubtargetFeature<
764    "addr-lsl-slow-14", "HasAddrLSLSlow14", "true",
765    "Address operands with shift amount of 1 or 4 are slow">;
766
767def FeatureALULSLFast : SubtargetFeature<
768    "alu-lsl-fast", "HasALULSLFast", "true",
769    "Add/Sub operations with lsl shift <= 4 are cheap">;
770
771def FeatureAggressiveFMA :
772  SubtargetFeature<"aggressive-fma",
773                   "HasAggressiveFMA",
774                   "true",
775                   "Enable Aggressive FMA for floating-point.">;
776
777def FeatureTaggedGlobals : SubtargetFeature<"tagged-globals",
778    "AllowTaggedGlobals",
779    "true", "Use an instruction sequence for taking the address of a global "
780    "that allows a memory tag in the upper address bits">;
781
782def FeatureEL2VMSA : SubtargetFeature<"el2vmsa", "HasEL2VMSA", "true",
783  "Enable Exception Level 2 Virtual Memory System Architecture">;
784
785def FeatureEL3 : SubtargetFeature<"el3", "HasEL3", "true",
786  "Enable Exception Level 3">;
787
788def FeatureFixCortexA53_835769 : SubtargetFeature<"fix-cortex-a53-835769",
789  "FixCortexA53_835769", "true", "Mitigate Cortex-A53 Erratum 835769">;
790
791def FeatureNoBTIAtReturnTwice : SubtargetFeature<"no-bti-at-return-twice",
792                                                 "NoBTIAtReturnTwice", "true",
793                                                 "Don't place a BTI instruction "
794                                                 "after a return-twice">;
795
796def FeatureDisableLdp : SubtargetFeature<"disable-ldp", "HasDisableLdp",
797    "true", "Do not emit ldp">;
798
799def FeatureDisableStp : SubtargetFeature<"disable-stp", "HasDisableStp",
800    "true", "Do not emit stp">;
801
802def FeatureLdpAlignedOnly : SubtargetFeature<"ldp-aligned-only", "HasLdpAlignedOnly",
803    "true", "In order to emit ldp, first check if the load will be aligned to 2 * element_size">;
804
805def FeatureStpAlignedOnly : SubtargetFeature<"stp-aligned-only", "HasStpAlignedOnly",
806    "true", "In order to emit stp, first check if the store will be aligned to 2 * element_size">;
807
808def FeatureUseFixedOverScalableIfEqualCost : SubtargetFeature<"use-fixed-over-scalable-if-equal-cost",
809  "UseFixedOverScalableIfEqualCost", "true",
810  "Prefer fixed width loop vectorization over scalable if the cost-model assigns equal costs">;
811
812// For performance reasons we prefer to use ldapr to ldapur on certain cores.
813def FeatureAvoidLDAPUR : SubtargetFeature<"avoid-ldapur", "AvoidLDAPUR", "true",
814  "Prefer add+ldapr to offset ldapur">;
815
816//===----------------------------------------------------------------------===//
817// Architectures.
818//
819class Architecture64<
820  int major, int minor, string profile,
821  string target_feature_name,
822  list<SubtargetFeature> implied_features,
823  list<Extension> default_extensions
824> : SubtargetFeature<target_feature_name,
825    "HasV" # major # "_" # minor # profile # "Ops", "true",
826    "Support ARM " # target_feature_name # " architecture",
827    implied_features
828> {
829  int Major = major;
830  int Minor = minor;
831  string Profile = profile;
832
833  // Extensions enabled by default. Not the same as implied SubtargetFeatures.
834  list<Extension> DefaultExts = default_extensions;
835}
836
837def HasV8_0aOps : Architecture64<8, 0, "a", "v8a",
838  [FeatureEL2VMSA, FeatureEL3],
839  [FeatureFPARMv8, FeatureNEON]>;
840def HasV8_1aOps : Architecture64<8, 1, "a", "v8.1a",
841  [HasV8_0aOps, FeatureCRC, FeatureLSE, FeatureRDM, FeaturePAN, FeatureLOR,
842   FeatureVH],
843  !listconcat(HasV8_0aOps.DefaultExts, [FeatureCRC, FeatureLSE, FeatureRDM])>;
844def HasV8_2aOps : Architecture64<8, 2, "a", "v8.2a",
845  [HasV8_1aOps, FeaturePsUAO, FeaturePAN_RWV, FeatureRAS, FeatureCCPP],
846  !listconcat(HasV8_1aOps.DefaultExts, [FeatureRAS])>;
847def HasV8_3aOps : Architecture64<8, 3, "a", "v8.3a",
848  [HasV8_2aOps, FeatureRCPC, FeaturePAuth, FeatureJS, FeatureComplxNum],
849  !listconcat(HasV8_2aOps.DefaultExts, [FeatureComplxNum, FeatureJS,
850    FeaturePAuth, FeatureRCPC,  FeatureCCIDX])>;
851def HasV8_4aOps : Architecture64<8, 4, "a", "v8.4a",
852  [HasV8_3aOps, FeatureDotProd, FeatureNV, FeatureMPAM, FeatureDIT,
853    FeatureTRACEV8_4, FeatureAM, FeatureSEL2, FeatureTLB_RMI, FeatureFlagM,
854    FeatureRCPC_IMMO, FeatureLSE2],
855  !listconcat(HasV8_3aOps.DefaultExts, [FeatureDotProd, FeatureDIT, FeatureFlagM])>;
856def HasV8_5aOps : Architecture64<8, 5, "a", "v8.5a",
857  [HasV8_4aOps, FeatureAltFPCmp, FeatureFRInt3264, FeatureSpecRestrict,
858    FeatureSB, FeaturePredRes, FeatureCacheDeepPersist,
859    FeatureBranchTargetId],
860  !listconcat(HasV8_4aOps.DefaultExts, [FeaturePredRes, FeatureSSBS, FeatureBranchTargetId, FeatureSB])>;
861def HasV8_6aOps : Architecture64<8, 6, "a", "v8.6a",
862  [HasV8_5aOps, FeatureAMVS, FeatureBF16, FeatureFineGrainedTraps,
863    FeatureEnhancedCounterVirtualization, FeatureMatMulInt8],
864  !listconcat(HasV8_5aOps.DefaultExts, [FeatureBF16, FeatureMatMulInt8])>;
865def HasV8_7aOps : Architecture64<8, 7, "a", "v8.7a",
866  [HasV8_6aOps, FeatureXS, FeatureWFxT, FeatureHCX],
867  !listconcat(HasV8_6aOps.DefaultExts, [FeatureWFxT, FeatureSPE_EEF])>;
868def HasV8_8aOps : Architecture64<8, 8, "a", "v8.8a",
869  [HasV8_7aOps, FeatureHBC, FeatureMOPS, FeatureNMI],
870  !listconcat(HasV8_7aOps.DefaultExts, [FeatureMOPS, FeatureHBC])>;
871def HasV8_9aOps : Architecture64<8, 9, "a", "v8.9a",
872  [HasV8_8aOps, FeatureCLRBHB, FeaturePRFM_SLC, FeatureSPECRES2,
873   FeatureCSSC, FeatureRASv2, FeatureCHK],
874  !listconcat(HasV8_8aOps.DefaultExts, [FeatureSPECRES2, FeatureCSSC,
875    FeatureRASv2])>;
876def HasV9_0aOps : Architecture64<9, 0, "a", "v9a",
877  [HasV8_5aOps],
878  !listconcat(HasV8_5aOps.DefaultExts, [FeatureFullFP16, FeatureSVE,
879    FeatureSVE2])>;
880def HasV9_1aOps : Architecture64<9, 1, "a", "v9.1a",
881  [HasV8_6aOps, HasV9_0aOps],
882  !listconcat(HasV9_0aOps.DefaultExts, HasV8_6aOps.DefaultExts,
883              [FeatureRME])>;
884def HasV9_2aOps : Architecture64<9, 2, "a", "v9.2a",
885  [HasV8_7aOps, HasV9_1aOps],
886  !listconcat(HasV9_1aOps.DefaultExts, HasV8_7aOps.DefaultExts,
887              [FeatureMEC])>;
888def HasV9_3aOps : Architecture64<9, 3, "a", "v9.3a",
889  [HasV8_8aOps, HasV9_2aOps],
890  !listconcat(HasV9_2aOps.DefaultExts, HasV8_8aOps.DefaultExts, [])>;
891def HasV9_4aOps : Architecture64<9, 4, "a", "v9.4a",
892  [HasV8_9aOps, HasV9_3aOps],
893  !listconcat(HasV9_3aOps.DefaultExts, HasV8_9aOps.DefaultExts,
894              [FeatureSVE2p1])>;
895def HasV9_5aOps : Architecture64<9, 5, "a", "v9.5a",
896  [HasV9_4aOps, FeatureCPA],
897  !listconcat(HasV9_4aOps.DefaultExts, [FeatureCPA,  FeatureLUT, FeatureFAMINMAX])>;
898def HasV9_6aOps : Architecture64<9, 6, "a", "v9.6a",
899  [HasV9_5aOps, FeatureCMPBR, FeatureFPRCVT, FeatureSVE2p2, FeatureLSUI, FeatureOCCMO],
900  !listconcat(HasV9_5aOps.DefaultExts, [FeatureCMPBR, FeatureFPRCVT, FeatureSVE2p2,
901    FeatureLSUI, FeatureOCCMO])>;
902def HasV8_0rOps : Architecture64<8, 0, "r", "v8r",
903  [ //v8.1
904    FeatureCRC, FeaturePAN, FeatureLSE, FeatureCONTEXTIDREL2,
905    //v8.2
906    FeatureRAS, FeaturePsUAO, FeatureCCPP, FeaturePAN_RWV,
907    //v8.3
908    FeaturePAuth, FeatureRCPC,
909    //v8.4
910    FeatureTRACEV8_4, FeatureTLB_RMI, FeatureFlagM, FeatureDIT, FeatureSEL2,
911    FeatureRCPC_IMMO,
912    // Not mandatory in v8.0-R, but included here on the grounds that it
913    // only enables names of system registers
914    FeatureSpecRestrict
915  ],
916  // For v8-R, we do not enable crypto and align with GCC that enables a more
917  // minimal set of optional architecture extensions.
918  !listconcat(
919    !listremove(HasV8_5aOps.DefaultExts, [FeatureBranchTargetId, FeaturePredRes]),
920    [FeatureSSBS, FeatureFullFP16, FeatureFP16FML, FeatureSB]
921  )>;
922
923//===----------------------------------------------------------------------===//
924// Access to privileged registers
925//===----------------------------------------------------------------------===//
926
927foreach i = 1-3 in
928def FeatureUseEL#i#ForTP : SubtargetFeature<"tpidr-el"#i, "UseEL"#i#"ForTP",
929  "true", "Permit use of TPIDR_EL"#i#" for the TLS base">;
930def FeatureUseROEL0ForTP : SubtargetFeature<"tpidrro-el0", "UseROEL0ForTP",
931  "true", "Permit use of TPIDRRO_EL0 for the TLS base">;
932
933//===----------------------------------------------------------------------===//
934// Control codegen mitigation against Straight Line Speculation vulnerability.
935//===----------------------------------------------------------------------===//
936
937def FeatureHardenSlsRetBr : SubtargetFeature<"harden-sls-retbr",
938  "HardenSlsRetBr", "true",
939  "Harden against straight line speculation across RET and BR instructions">;
940def FeatureHardenSlsBlr : SubtargetFeature<"harden-sls-blr",
941  "HardenSlsBlr", "true",
942  "Harden against straight line speculation across BLR instructions">;
943def FeatureHardenSlsNoComdat : SubtargetFeature<"harden-sls-nocomdat",
944  "HardenSlsNoComdat", "true",
945  "Generate thunk code for SLS mitigation in the normal text section">;
946
947
948// Only intended to be used by disassemblers.
949def FeatureAll
950    : SubtargetFeature<"all", "IsAll", "true", "Enable all instructions">;
951