xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64Features.td (revision e64bea71c21eb42e97aa615188ba91f6cce0d36d)
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 FeatureSVESM4 : ExtensionWithMArch<"sve-sm4", "SVESM4", "FEAT_SVE_SM4",
374  "Enable SVE SM4 instructions", [FeatureSM4]>;
375
376def FeatureAliasSVE2SM4 : ExtensionWithMArch<"sve2-sm4", "SVE2SM4",
377  "", "Shorthand for +sve2+sve-sm4", [FeatureSVE2, FeatureSVESM4]>;
378
379def FeatureSVESHA3 : ExtensionWithMArch<"sve-sha3", "SVESHA3", "FEAT_SVE_SHA3",
380  "Enable SVE SHA3 instructions", [FeatureSHA3]>;
381
382def FeatureAliasSVE2SHA3 : ExtensionWithMArch<"sve2-sha3", "SVE2SHA3",
383  "", "Shorthand for +sve2+sve-sha3", [FeatureSVE2, FeatureSVESHA3]>;
384
385def FeatureSVEBitPerm : ExtensionWithMArch<"sve-bitperm", "SVEBitPerm",
386  "FEAT_SVE_BitPerm",  "Enable bit permutation SVE2 instructions">;
387
388def FeatureAliasSVE2BitPerm : ExtensionWithMArch<"sve2-bitperm", "SVE2BitPerm",
389  "",  "Shorthand for +sve2+sve-bitperm", [FeatureSVE2, FeatureSVEBitPerm]>;
390
391def FeatureTRBE : Extension<"trbe", "TRBE", "FEAT_TRBE",
392  "Enable Trace Buffer Extension">;
393
394def FeatureETE : Extension<"ete", "ETE", "FEAT_ETE",
395  "Enable Embedded Trace Extension", [FeatureTRBE]>;
396
397def FeatureTME : ExtensionWithMArch<"tme", "TME", "FEAT_TME",
398  "Enable Transactional Memory Extension">;
399
400//===----------------------------------------------------------------------===//
401//  Armv9.1 Architecture Extensions
402//===----------------------------------------------------------------------===//
403
404//===----------------------------------------------------------------------===//
405//  Armv9.2 Architecture Extensions
406//===----------------------------------------------------------------------===//
407
408def FeatureBRBE : ExtensionWithMArch<"brbe", "BRBE", "FEAT_BRBE",
409  "Enable Branch Record Buffer Extension">;
410
411def FeatureRME : Extension<"rme", "RME", "FEAT_RME",
412  "Enable Realm Management Extension">;
413
414def FeatureSME : ExtensionWithMArch<"sme", "SME", "FEAT_SME",
415  "Enable Scalable Matrix Extension (SME)", [FeatureBF16, FeatureFullFP16]>;
416
417def FeatureSMEF64F64 : ExtensionWithMArch<"sme-f64f64", "SMEF64F64", "FEAT_SME_F64F64",
418  "Enable Scalable Matrix Extension (SME) F64F64 instructions", [FeatureSME]>;
419
420def FeatureSMEI16I64 : ExtensionWithMArch<"sme-i16i64", "SMEI16I64", "FEAT_SME_I16I64",
421  "Enable Scalable Matrix Extension (SME) I16I64 instructions", [FeatureSME]>;
422
423def FeatureSMEFA64 : ExtensionWithMArch<"sme-fa64", "SMEFA64", "FEAT_SME_FA64",
424  "Enable the full A64 instruction set in streaming SVE mode", [FeatureSME, FeatureSVE2]>;
425
426//===----------------------------------------------------------------------===//
427//  Armv9.3 Architecture Extensions
428//===----------------------------------------------------------------------===//
429
430def FeatureSME2 : ExtensionWithMArch<"sme2", "SME2", "FEAT_SME2",
431  "Enable Scalable Matrix Extension 2 (SME2) instructions", [FeatureSME]>;
432
433def FeatureMEC : Extension<"mec", "MEC", "FEAT_MEC",
434  "Enable Memory Encryption Contexts Extension", [FeatureRME]>;
435
436//===----------------------------------------------------------------------===//
437//  Armv9.4 Architecture Extensions
438//===----------------------------------------------------------------------===//
439
440def FeatureSVE2p1: ExtensionWithMArch<"sve2p1", "SVE2p1", "FEAT_SVE2p1",
441  "Enable Scalable Vector Extension 2.1 instructions", [FeatureSVE2]>;
442
443def FeatureSVEB16B16: ExtensionWithMArch<"sve-b16b16", "SVEB16B16", "FEAT_SVE_B16B16",
444  "Enable SVE2 non-widening and SME2 Z-targeting non-widening BFloat16 instructions">;
445
446def FeatureSMEB16B16 : ExtensionWithMArch<"sme-b16b16", "SMEB16B16", "FEAT_SME_B16B16",
447  "Enable SME2.1 ZA-targeting non-widening BFloat16 instructions",
448  [FeatureSME2, FeatureSVEB16B16]>;
449
450def FeatureSMEF16F16 : ExtensionWithMArch<"sme-f16f16", "SMEF16F16", "FEAT_SME_F16F16",
451  "Enable SME non-widening Float16 instructions", [FeatureSME2]>;
452
453def FeatureSME2p1 : ExtensionWithMArch<"sme2p1", "SME2p1", "FEAT_SME2p1",
454  "Enable Scalable Matrix Extension 2.1 instructions", [FeatureSME2]>;
455
456def FeatureCHK : Extension<"chk", "CHK", "FEAT_CHK",
457  "Enable Armv8.0-A Check Feature Status Extension">;
458
459def FeatureGCS : ExtensionWithMArch<"gcs", "GCS", "FEAT_GCS",
460  "Enable Armv9.4-A Guarded Call Stack Extension", [FeatureCHK]>;
461
462def FeatureITE : ExtensionWithMArch<"ite", "ITE", "FEAT_ITE",
463  "Enable Armv9.4-A Instrumentation Extension", [FeatureETE, FeatureTRBE]>;
464
465def FeatureLSE128 : ExtensionWithMArch<"lse128", "LSE128", "FEAT_LSE128",
466  "Enable Armv9.4-A 128-bit Atomic instructions",
467  [FeatureLSE]>;
468
469// FEAT_D128, FEAT_LVA3, FEAT_SYSREG128, and FEAT_SYSINSTR128 are mutually implicit.
470// Therefore group them all under a single feature flag, d128:
471def FeatureD128 : ExtensionWithMArch<"d128", "D128",
472  "FEAT_D128, FEAT_LVA3, FEAT_SYSREG128, FEAT_SYSINSTR128",
473  "Enable Armv9.4-A 128-bit Page Table Descriptors, System Registers "
474  "and instructions",
475  [FeatureLSE128]>;
476
477//===----------------------------------------------------------------------===//
478//  Armv9.5 Architecture Extensions
479//===----------------------------------------------------------------------===//
480
481def FeatureFAMINMAX: ExtensionWithMArch<"faminmax", "FAMINMAX", "FEAT_FAMINMAX",
482 "Enable FAMIN and FAMAX instructions", [FeatureNEON]>;
483
484def FeatureLUT: ExtensionWithMArch<"lut", "LUT", "FEAT_LUT",
485 "Enable Lookup Table instructions", [FeatureNEON]>;
486
487def FeatureFP8 : ExtensionWithMArch<"fp8", "FP8", "FEAT_FP8",
488  "Enable FP8 instructions", [FeatureNEON]>;
489
490def FeatureFP8FMA : ExtensionWithMArch<"fp8fma", "FP8FMA", "FEAT_FP8FMA",
491  "Enable Armv9.5-A FP8 multiply-add instructions", [FeatureFP8]>;
492
493def FeatureSSVE_FP8FMA : ExtensionWithMArch<"ssve-fp8fma", "SSVE_FP8FMA", "FEAT_SSVE_FP8FMA",
494  "Enable SVE2 FP8 multiply-add instructions", [FeatureSME2, FeatureFP8]>;
495
496def FeatureFP8DOT4: ExtensionWithMArch<"fp8dot4", "FP8DOT4", "FEAT_FP8DOT4",
497  "Enable FP8 4-way dot instructions", [FeatureFP8]>;
498
499def FeatureFP8DOT2: ExtensionWithMArch<"fp8dot2", "FP8DOT2", "FEAT_FP8DOT2",
500  "Enable FP8 2-way dot instructions", [FeatureFP8]>;
501
502def FeatureSSVE_FP8DOT4 : ExtensionWithMArch<"ssve-fp8dot4", "SSVE_FP8DOT4", "FEAT_SSVE_FP8DOT4",
503  "Enable SVE2 FP8 4-way dot product instructions", [FeatureSME2, FeatureFP8]>;
504
505def FeatureSSVE_FP8DOT2 : ExtensionWithMArch<"ssve-fp8dot2", "SSVE_FP8DOT2", "FEAT_SSVE_FP8DOT2",
506  "Enable SVE2 FP8 2-way dot product instructions", [FeatureSME2, FeatureFP8]>;
507
508def FeatureSME_LUTv2 : ExtensionWithMArch<"sme-lutv2", "SME_LUTv2", "FEAT_SME_LUTv2",
509  "Enable Scalable Matrix Extension (SME) LUTv2 instructions", [FeatureSME2]>;
510
511def FeatureSMEF8F32 : ExtensionWithMArch<"sme-f8f32", "SMEF8F32", "FEAT_SME_F8F32",
512  "Enable Scalable Matrix Extension (SME) F8F32 instructions", [FeatureSME2, FeatureFP8]>;
513
514def FeatureSMEF8F16 : ExtensionWithMArch<"sme-f8f16", "SMEF8F16", "FEAT_SME_F8F16",
515  "Enable Scalable Matrix Extension (SME) F8F16 instructions", [FeatureSME2, FeatureFP8]>;
516
517def FeatureCPA : ExtensionWithMArch<"cpa", "CPA", "FEAT_CPA",
518  "Enable Armv9.5-A Checked Pointer Arithmetic">;
519
520def FeaturePAuthLR : ExtensionWithMArch<"pauth-lr", "PAuthLR", "FEAT_PAuth_LR",
521  "Enable Armv9.5-A PAC enhancements">;
522
523def FeatureTLBIW : ExtensionWithMArch<"tlbiw", "TLBIW", "FEAT_TLBIW",
524  "Enable Armv9.5-A TLBI VMALL for Dirty State">;
525
526//===----------------------------------------------------------------------===//
527//  Armv9.6 Architecture Extensions
528//===----------------------------------------------------------------------===//
529
530def FeatureCMPBR : ExtensionWithMArch<"cmpbr", "CMPBR", "FEAT_CMPBR",
531  "Enable Armv9.6-A base compare and branch instructions">;
532
533def FeatureF8F32MM: ExtensionWithMArch<"f8f32mm", "F8F32MM", "FEAT_F8F32MM",
534  "Enable Armv9.6-A FP8 to Single-Precision Matrix Multiplication", [FeatureNEON, FeatureFP8]>;
535
536def FeatureF8F16MM: ExtensionWithMArch<"f8f16mm", "F8F16MM", "FEAT_F8F16MM",
537  "Enable Armv9.6-A FP8 to Half-Precision Matrix Multiplication", [FeatureNEON, FeatureFP8]>;
538
539def FeatureFPRCVT: ExtensionWithMArch<"fprcvt", "FPRCVT", "FEAT_FPRCVT",
540  "Enable Armv9.6-A base convert instructions for SIMD&FP scalar register operands of"
541  " different input and output sizes", [FeatureFPARMv8]>;
542
543def FeatureLSFE : ExtensionWithMArch<"lsfe", "LSFE", "FEAT_LSFE",
544  "Enable Armv9.6-A base Atomic floating-point in-memory instructions", [FeatureFPARMv8]>;
545
546def FeatureSME2p2: ExtensionWithMArch<"sme2p2", "SME2p2", "FEAT_SME2p2",
547  "Enable Armv9.6-A Scalable Matrix Extension 2.2 instructions", [FeatureSME2p1]>;
548
549def FeatureSSVE_AES : ExtensionWithMArch<"ssve-aes", "SSVE_AES", "FEAT_SSVE_AES",
550  "Enable Armv9.6-A SVE AES support in streaming SVE mode", [FeatureSME2, FeatureSVEAES]>;
551
552def FeatureSVE2p2 : ExtensionWithMArch<"sve2p2", "SVE2p2", "FEAT_SVE2p2",
553  "Enable Armv9.6-A Scalable Vector Extension 2.2 instructions", [FeatureSVE2p1]>;
554
555def FeatureSVEAES2: ExtensionWithMArch<"sve-aes2", "SVE_AES2", "FEAT_SVE_AES2",
556  "Enable Armv9.6-A SVE multi-vector AES and multi-vector quadword polynomial multiply instructions">;
557
558def FeatureSVEBFSCALE: ExtensionWithMArch<"sve-bfscale", "SVE_BFSCALE", "FEAT_SVE_BFSCALE",
559  "Enable Armv9.6-A SVE BFloat16 scaling instructions">;
560
561def FeatureSVE_F16F32MM: ExtensionWithMArch<"sve-f16f32mm", "SVE_F16F32MM", "FEAT_SVE_F16F32MM",
562  "Enable Armv9.6-A FP16 to FP32 Matrix Multiply instructions", [FeatureSVE]>;
563
564def FeatureLSUI: ExtensionWithMArch<"lsui", "LSUI", "FEAT_LSUI",
565  "Enable Armv9.6-A unprivileged load/store instructions">;
566
567def FeatureOCCMO: ExtensionWithMArch<"occmo", "OCCMO", "FEAT_OCCMO",
568  "Enable Armv9.6-A Outer cacheable cache maintenance operations">;
569
570def FeaturePCDPHINT: ExtensionWithMArch<"pcdphint", "PCDPHINT", "FEAT_PCDPHINT",
571  "Enable Armv9.6-A Producer Consumer Data Placement hints">;
572
573def FeaturePoPS: ExtensionWithMArch<"pops", "PoPS", "FEAT_PoPS",
574  "Enable Armv9.6-A Point Of Physical Storage (PoPS) DC instructions">;
575
576def FeatureSSVE_BitPerm : ExtensionWithMArch<"ssve-bitperm", "SSVE_BitPerm", "FEAT_SSVE_BitPerm",
577  "Enable Armv9.6-A SVE BitPerm support in streaming SVE mode", [FeatureSME2, FeatureSVEBitPerm]>;
578
579def FeatureSME_MOP4: ExtensionWithMArch<"sme-mop4", "SME_MOP4", "FEAT_SME_MOP4",
580  "Enable SME Quarter-tile outer product instructions", [FeatureSME2]>;
581
582def FeatureSME_TMOP: ExtensionWithMArch<"sme-tmop", "SME_TMOP", "FEAT_SME_TMOP",
583  "Enable SME Structured sparsity outer product instructions.", [FeatureSME2]>;
584
585def FeatureSSVE_FEXPA : ExtensionWithMArch<"ssve-fexpa", "SSVE_FEXPA", "FEAT_SSVE_FEXPA",
586  "Enable SVE FEXPA instruction in Streaming SVE mode", [FeatureSME2]>;
587
588//  Other Features
589//===----------------------------------------------------------------------===//
590
591def FeatureOutlineAtomics : SubtargetFeature<"outline-atomics", "OutlineAtomics", "true",
592  "Enable out of line atomics to support LSE instructions">;
593
594def FeatureFMV : SubtargetFeature<"fmv", "HasFMV", "true",
595  "Enable Function Multi Versioning support.">;
596
597// This flag is currently still labeled as Experimental, but when fully
598// implemented this should tell the compiler to use the zeroing pseudos to
599// benefit from the reverse instructions (e.g. SUB vs SUBR) if the inactive
600// lanes are known to be zero. The pseudos will then be expanded using the
601// MOVPRFX instruction to zero the inactive lanes. This feature should only be
602// enabled if MOVPRFX instructions are known to merge with the destructive
603// operations they prefix.
604//
605// This feature could similarly be extended to support cheap merging of _any_
606// value into the inactive lanes using the MOVPRFX instruction that uses
607// merging-predication.
608def FeatureExperimentalZeroingPseudos
609    : SubtargetFeature<"use-experimental-zeroing-pseudos",
610                       "UseExperimentalZeroingPseudos", "true",
611                       "Hint to the compiler that the MOVPRFX instruction is "
612                       "merged with destructive operations",
613                       []>;
614
615def FeatureNoSVEFPLD1R : SubtargetFeature<"no-sve-fp-ld1r",
616  "NoSVEFPLD1R", "true", "Avoid using LD1RX instructions for FP">;
617
618def FeatureZCRegMoveGPR64 : SubtargetFeature<"zcm-gpr64", "HasZeroCycleRegMoveGPR64", "true",
619                                        "Has zero-cycle register moves for GPR64 registers">;
620
621def FeatureZCRegMoveGPR32 : SubtargetFeature<"zcm-gpr32", "HasZeroCycleRegMoveGPR32", "true",
622                                        "Has zero-cycle register moves for GPR32 registers">;
623
624def FeatureZCRegMoveFPR64 : SubtargetFeature<"zcm-fpr64", "HasZeroCycleRegMoveFPR64", "true",
625                                        "Has zero-cycle register moves for FPR64 registers">;
626
627def FeatureZCRegMoveFPR32 : SubtargetFeature<"zcm-fpr32", "HasZeroCycleRegMoveFPR32", "true",
628                                        "Has zero-cycle register moves for FPR32 registers">;
629
630def FeatureZCZeroingGP : SubtargetFeature<"zcz-gp", "HasZeroCycleZeroingGP", "true",
631                                        "Has zero-cycle zeroing instructions for generic registers">;
632
633// It is generally beneficial to rewrite "fmov s0, wzr" to "movi d0, #0".
634// as movi is more efficient across all cores. Newer cores can eliminate
635// fmovs early and there is no difference with movi, but this not true for
636// all implementations.
637def FeatureNoZCZeroingFP : SubtargetFeature<"no-zcz-fp", "HasZeroCycleZeroingFP", "false",
638                                        "Has no zero-cycle zeroing instructions for FP registers">;
639
640def FeatureZCZeroing : SubtargetFeature<"zcz", "HasZeroCycleZeroing", "true",
641                                        "Has zero-cycle zeroing instructions",
642                                        [FeatureZCZeroingGP]>;
643
644/// ... but the floating-point version doesn't quite work in rare cases on older
645/// CPUs.
646def FeatureZCZeroingFPWorkaround : SubtargetFeature<"zcz-fp-workaround",
647    "HasZeroCycleZeroingFPWorkaround", "true",
648    "The zero-cycle floating-point zeroing instruction has a bug">;
649
650def FeatureStrictAlign : SubtargetFeature<"strict-align",
651                                          "RequiresStrictAlign", "true",
652                                          "Disallow all unaligned memory "
653                                          "access">;
654
655def FeatureExecuteOnly : SubtargetFeature<"execute-only",
656                                          "GenExecuteOnly", "true",
657                                          "Enable the generation of "
658                                          "execute only code.">;
659
660foreach i = {1-7,9-15,18,20-28} in
661    def FeatureReserveX#i : SubtargetFeature<"reserve-x"#i, "ReserveXRegister["#i#"]", "true",
662                                             "Reserve X"#i#", making it unavailable "
663                                             "as a GPR">;
664
665def FeatureReserveLRForRA : SubtargetFeature<"reserve-lr-for-ra",
666                                             "ReserveLRForRA", "true",
667                                             "Reserve LR for call use only">;
668
669foreach i = {8-15,18} in
670    def FeatureCallSavedX#i : SubtargetFeature<"call-saved-x"#i,
671         "CustomCallSavedXRegs["#i#"]", "true", "Make X"#i#" callee saved.">;
672
673def FeatureBalanceFPOps : SubtargetFeature<"balance-fp-ops", "BalanceFPOps",
674    "true",
675    "balance mix of odd and even D-registers for fp multiply(-accumulate) ops">;
676
677def FeaturePredictableSelectIsExpensive : SubtargetFeature<
678    "predictable-select-expensive", "PredictableSelectIsExpensive", "true",
679    "Prefer likely predicted branches over selects">;
680
681def FeatureEnableSelectOptimize : SubtargetFeature<
682    "enable-select-opt", "EnableSelectOptimize", "true",
683    "Enable the select optimize pass for select loop heuristics">;
684
685def FeatureExynosCheapAsMoveHandling : SubtargetFeature<"exynos-cheap-as-move",
686    "HasExynosCheapAsMoveHandling", "true",
687    "Use Exynos specific handling of cheap instructions">;
688
689def FeaturePostRAScheduler : SubtargetFeature<"use-postra-scheduler",
690    "UsePostRAScheduler", "true", "Schedule again after register allocation">;
691
692def FeatureSlowMisaligned128Store : SubtargetFeature<"slow-misaligned-128store",
693    "IsMisaligned128StoreSlow", "true", "Misaligned 128 bit stores are slow">;
694
695def FeatureSlowPaired128 : SubtargetFeature<"slow-paired-128",
696    "IsPaired128Slow", "true", "Paired 128 bit loads and stores are slow">;
697
698def FeatureAscendStoreAddress : SubtargetFeature<"ascend-store-address",
699    "IsStoreAddressAscend", "true",
700    "Schedule vector stores by ascending address">;
701
702def FeatureSlowSTRQro : SubtargetFeature<"slow-strqro-store", "IsSTRQroSlow",
703    "true", "STR of Q register with register offset is slow">;
704
705def FeatureAlternateSExtLoadCVTF32Pattern : SubtargetFeature<
706    "alternate-sextload-cvt-f32-pattern", "UseAlternateSExtLoadCVTF32Pattern",
707    "true", "Use alternative pattern for sextload convert to f32">;
708
709def FeatureArithmeticBccFusion : SubtargetFeature<
710    "arith-bcc-fusion", "HasArithmeticBccFusion", "true",
711    "CPU fuses arithmetic+bcc operations">;
712
713def FeatureArithmeticCbzFusion : SubtargetFeature<
714    "arith-cbz-fusion", "HasArithmeticCbzFusion", "true",
715    "CPU fuses arithmetic + cbz/cbnz operations">;
716
717def FeatureCmpBccFusion : SubtargetFeature<
718    "cmp-bcc-fusion", "HasCmpBccFusion", "true",
719    "CPU fuses cmp+bcc operations">;
720
721def FeatureFuseAddress : SubtargetFeature<
722    "fuse-address", "HasFuseAddress", "true",
723    "CPU fuses address generation and memory operations">;
724
725def FeatureFuseAES : SubtargetFeature<
726    "fuse-aes", "HasFuseAES", "true",
727    "CPU fuses AES crypto operations">;
728
729def FeatureFuseArithmeticLogic : SubtargetFeature<
730    "fuse-arith-logic", "HasFuseArithmeticLogic", "true",
731    "CPU fuses arithmetic and logic operations">;
732
733def FeatureFuseCCSelect : SubtargetFeature<
734    "fuse-csel", "HasFuseCCSelect", "true",
735    "CPU fuses conditional select operations">;
736
737def FeatureFuseCryptoEOR : SubtargetFeature<
738    "fuse-crypto-eor", "HasFuseCryptoEOR", "true",
739    "CPU fuses AES/PMULL and EOR operations">;
740
741def FeatureFuseAdrpAdd : SubtargetFeature<
742    "fuse-adrp-add", "HasFuseAdrpAdd", "true",
743    "CPU fuses adrp+add operations">;
744
745def FeatureFuseLiterals : SubtargetFeature<
746    "fuse-literals", "HasFuseLiterals", "true",
747    "CPU fuses literal generation operations">;
748
749def FeatureFuseAddSub2RegAndConstOne : SubtargetFeature<
750   "fuse-addsub-2reg-const1", "HasFuseAddSub2RegAndConstOne", "true",
751   "CPU fuses (a + b + 1) and (a - b - 1)">;
752
753def FeatureDisableLatencySchedHeuristic : SubtargetFeature<
754    "disable-latency-sched-heuristic", "DisableLatencySchedHeuristic", "true",
755    "Disable latency scheduling heuristic">;
756
757def FeatureStorePairSuppress : SubtargetFeature<
758    "store-pair-suppress", "EnableStorePairSuppress", "true",
759    "Enable Store Pair Suppression heuristics">;
760
761def FeatureForce32BitJumpTables
762   : SubtargetFeature<"force-32bit-jump-tables", "Force32BitJumpTables", "true",
763                      "Force jump table entries to be 32-bits wide except at MinSize">;
764
765def FeatureUseRSqrt : SubtargetFeature<
766    "use-reciprocal-square-root", "UseRSqrt", "true",
767    "Use the reciprocal square root approximation">;
768
769def FeatureNoNegativeImmediates : SubtargetFeature<"no-neg-immediates",
770                                        "NegativeImmediates", "false",
771                                        "Convert immediates and instructions "
772                                        "to their negated or complemented "
773                                        "equivalent when the immediate does "
774                                        "not fit in the encoding.">;
775
776// Address operands with shift amount 2 or 3 are fast on all Arm chips except
777// some old Apple cores (A7-A10?) which handle all shifts slowly. Cortex-A57
778// and derived designs through Cortex-X1 take an extra micro-op for shifts
779// of 1 or 4. Other Arm chips handle all shifted operands at the same speed
780// as unshifted operands.
781//
782// We don't try to model the behavior of the old Apple cores because new code
783// targeting A7 is very unlikely to actually run on an A7. The Cortex cores
784// are modeled by FeatureAddrLSLSlow14.
785def FeatureAddrLSLSlow14 : SubtargetFeature<
786    "addr-lsl-slow-14", "HasAddrLSLSlow14", "true",
787    "Address operands with shift amount of 1 or 4 are slow">;
788
789def FeatureALULSLFast : SubtargetFeature<
790    "alu-lsl-fast", "HasALULSLFast", "true",
791    "Add/Sub operations with lsl shift <= 4 are cheap">;
792
793def FeatureAggressiveFMA :
794  SubtargetFeature<"aggressive-fma",
795                   "HasAggressiveFMA",
796                   "true",
797                   "Enable Aggressive FMA for floating-point.">;
798
799def FeatureTaggedGlobals : SubtargetFeature<"tagged-globals",
800    "AllowTaggedGlobals",
801    "true", "Use an instruction sequence for taking the address of a global "
802    "that allows a memory tag in the upper address bits">;
803
804def FeatureEL2VMSA : SubtargetFeature<"el2vmsa", "HasEL2VMSA", "true",
805  "Enable Exception Level 2 Virtual Memory System Architecture">;
806
807def FeatureEL3 : SubtargetFeature<"el3", "HasEL3", "true",
808  "Enable Exception Level 3">;
809
810def FeatureFixCortexA53_835769 : SubtargetFeature<"fix-cortex-a53-835769",
811  "FixCortexA53_835769", "true", "Mitigate Cortex-A53 Erratum 835769">;
812
813def FeatureNoBTIAtReturnTwice : SubtargetFeature<"no-bti-at-return-twice",
814                                                 "NoBTIAtReturnTwice", "true",
815                                                 "Don't place a BTI instruction "
816                                                 "after a return-twice">;
817
818def FeatureDisableLdp : SubtargetFeature<"disable-ldp", "HasDisableLdp",
819    "true", "Do not emit ldp">;
820
821def FeatureDisableStp : SubtargetFeature<"disable-stp", "HasDisableStp",
822    "true", "Do not emit stp">;
823
824def FeatureLdpAlignedOnly : SubtargetFeature<"ldp-aligned-only", "HasLdpAlignedOnly",
825    "true", "In order to emit ldp, first check if the load will be aligned to 2 * element_size">;
826
827def FeatureStpAlignedOnly : SubtargetFeature<"stp-aligned-only", "HasStpAlignedOnly",
828    "true", "In order to emit stp, first check if the store will be aligned to 2 * element_size">;
829
830def FeatureUseFixedOverScalableIfEqualCost : SubtargetFeature<"use-fixed-over-scalable-if-equal-cost",
831  "UseFixedOverScalableIfEqualCost", "true",
832  "Prefer fixed width loop vectorization over scalable if the cost-model assigns equal costs">;
833
834// For performance reasons we prefer to use ldapr to ldapur on certain cores.
835def FeatureAvoidLDAPUR : SubtargetFeature<"avoid-ldapur", "AvoidLDAPUR", "true",
836  "Prefer add+ldapr to offset ldapur">;
837
838// Some INC/DEC forms have better latency and throughput than ADDVL.
839def FeatureDisableFastIncVL : SubtargetFeature<"disable-fast-inc-vl",
840                                               "HasDisableFastIncVL", "true",
841                                               "Do not prefer INC/DEC, ALL, { 1, 2, 4 } over ADDVL">;
842
843//===----------------------------------------------------------------------===//
844// Architectures.
845//
846class Architecture64<
847  int major, int minor, string profile,
848  string target_feature_name,
849  list<SubtargetFeature> implied_features,
850  list<Extension> default_extensions
851> : SubtargetFeature<target_feature_name,
852    "HasV" # major # "_" # minor # profile # "Ops", "true",
853    "Support ARM " # target_feature_name # " architecture",
854    implied_features
855> {
856  int Major = major;
857  int Minor = minor;
858  string Profile = profile;
859
860  // Extensions enabled by default. Not the same as implied SubtargetFeatures.
861  list<Extension> DefaultExts = default_extensions;
862}
863
864def HasV8_0aOps : Architecture64<8, 0, "a", "v8a",
865  [FeatureEL2VMSA, FeatureEL3],
866  [FeatureFPARMv8, FeatureNEON]>;
867def HasV8_1aOps : Architecture64<8, 1, "a", "v8.1a",
868  [HasV8_0aOps, FeatureCRC, FeatureLSE, FeatureRDM, FeaturePAN, FeatureLOR,
869   FeatureVH],
870  !listconcat(HasV8_0aOps.DefaultExts, [FeatureCRC, FeatureLSE, FeatureRDM])>;
871def HasV8_2aOps : Architecture64<8, 2, "a", "v8.2a",
872  [HasV8_1aOps, FeaturePsUAO, FeaturePAN_RWV, FeatureRAS, FeatureCCPP],
873  !listconcat(HasV8_1aOps.DefaultExts, [FeatureRAS])>;
874def HasV8_3aOps : Architecture64<8, 3, "a", "v8.3a",
875  [HasV8_2aOps, FeatureRCPC, FeaturePAuth, FeatureJS, FeatureComplxNum],
876  !listconcat(HasV8_2aOps.DefaultExts, [FeatureComplxNum, FeatureJS,
877    FeaturePAuth, FeatureRCPC,  FeatureCCIDX])>;
878def HasV8_4aOps : Architecture64<8, 4, "a", "v8.4a",
879  [HasV8_3aOps, FeatureDotProd, FeatureNV, FeatureMPAM, FeatureDIT,
880    FeatureTRACEV8_4, FeatureAM, FeatureSEL2, FeatureTLB_RMI, FeatureFlagM,
881    FeatureRCPC_IMMO, FeatureLSE2],
882  !listconcat(HasV8_3aOps.DefaultExts, [FeatureDotProd, FeatureDIT, FeatureFlagM])>;
883def HasV8_5aOps : Architecture64<8, 5, "a", "v8.5a",
884  [HasV8_4aOps, FeatureAltFPCmp, FeatureFRInt3264, FeatureSpecRestrict,
885    FeatureSB, FeaturePredRes, FeatureCacheDeepPersist,
886    FeatureBranchTargetId],
887  !listconcat(HasV8_4aOps.DefaultExts, [FeaturePredRes, FeatureSSBS, FeatureBranchTargetId, FeatureSB])>;
888def HasV8_6aOps : Architecture64<8, 6, "a", "v8.6a",
889  [HasV8_5aOps, FeatureAMVS, FeatureBF16, FeatureFineGrainedTraps,
890    FeatureEnhancedCounterVirtualization, FeatureMatMulInt8],
891  !listconcat(HasV8_5aOps.DefaultExts, [FeatureBF16, FeatureMatMulInt8])>;
892def HasV8_7aOps : Architecture64<8, 7, "a", "v8.7a",
893  [HasV8_6aOps, FeatureXS, FeatureWFxT, FeatureHCX],
894  !listconcat(HasV8_6aOps.DefaultExts, [FeatureWFxT, FeatureSPE_EEF])>;
895def HasV8_8aOps : Architecture64<8, 8, "a", "v8.8a",
896  [HasV8_7aOps, FeatureHBC, FeatureMOPS, FeatureNMI],
897  !listconcat(HasV8_7aOps.DefaultExts, [FeatureMOPS, FeatureHBC])>;
898def HasV8_9aOps : Architecture64<8, 9, "a", "v8.9a",
899  [HasV8_8aOps, FeatureCLRBHB, FeaturePRFM_SLC, FeatureSPECRES2,
900   FeatureCSSC, FeatureRASv2, FeatureCHK],
901  !listconcat(HasV8_8aOps.DefaultExts, [FeatureSPECRES2, FeatureCSSC,
902    FeatureRASv2])>;
903def HasV9_0aOps : Architecture64<9, 0, "a", "v9a",
904  [HasV8_5aOps],
905  !listconcat(HasV8_5aOps.DefaultExts, [FeatureFullFP16, FeatureSVE,
906    FeatureSVE2])>;
907def HasV9_1aOps : Architecture64<9, 1, "a", "v9.1a",
908  [HasV8_6aOps, HasV9_0aOps],
909  !listconcat(HasV9_0aOps.DefaultExts, HasV8_6aOps.DefaultExts,
910              [FeatureRME])>;
911def HasV9_2aOps : Architecture64<9, 2, "a", "v9.2a",
912  [HasV8_7aOps, HasV9_1aOps],
913  !listconcat(HasV9_1aOps.DefaultExts, HasV8_7aOps.DefaultExts,
914              [FeatureMEC])>;
915def HasV9_3aOps : Architecture64<9, 3, "a", "v9.3a",
916  [HasV8_8aOps, HasV9_2aOps],
917  !listconcat(HasV9_2aOps.DefaultExts, HasV8_8aOps.DefaultExts, [])>;
918def HasV9_4aOps : Architecture64<9, 4, "a", "v9.4a",
919  [HasV8_9aOps, HasV9_3aOps],
920  !listconcat(HasV9_3aOps.DefaultExts, HasV8_9aOps.DefaultExts,
921              [FeatureSVE2p1])>;
922def HasV9_5aOps : Architecture64<9, 5, "a", "v9.5a",
923  [HasV9_4aOps, FeatureCPA],
924  !listconcat(HasV9_4aOps.DefaultExts, [FeatureCPA,  FeatureLUT, FeatureFAMINMAX])>;
925def HasV9_6aOps : Architecture64<9, 6, "a", "v9.6a",
926  [HasV9_5aOps, FeatureCMPBR, FeatureLSUI, FeatureOCCMO],
927  !listconcat(HasV9_5aOps.DefaultExts, [FeatureCMPBR,
928    FeatureLSUI, FeatureOCCMO])>;
929def HasV8_0rOps : Architecture64<8, 0, "r", "v8r",
930  [ //v8.1
931    FeatureCRC, FeaturePAN, FeatureLSE, FeatureCONTEXTIDREL2,
932    //v8.2
933    FeatureRAS, FeaturePsUAO, FeatureCCPP, FeaturePAN_RWV,
934    //v8.3
935    FeaturePAuth, FeatureRCPC,
936    //v8.4
937    FeatureTRACEV8_4, FeatureTLB_RMI, FeatureFlagM, FeatureDIT, FeatureSEL2,
938    FeatureRCPC_IMMO,
939    // Not mandatory in v8.0-R, but included here on the grounds that it
940    // only enables names of system registers
941    FeatureSpecRestrict
942  ],
943  // For v8-R, we do not enable crypto and align with GCC that enables a more
944  // minimal set of optional architecture extensions.
945  !listconcat(
946    !listremove(HasV8_5aOps.DefaultExts, [FeatureBranchTargetId, FeaturePredRes]),
947    [FeatureSSBS, FeatureFullFP16, FeatureFP16FML, FeatureSB]
948  )>;
949
950//===----------------------------------------------------------------------===//
951// Access to privileged registers
952//===----------------------------------------------------------------------===//
953
954foreach i = 1-3 in
955def FeatureUseEL#i#ForTP : SubtargetFeature<"tpidr-el"#i, "UseEL"#i#"ForTP",
956  "true", "Permit use of TPIDR_EL"#i#" for the TLS base">;
957def FeatureUseROEL0ForTP : SubtargetFeature<"tpidrro-el0", "UseROEL0ForTP",
958  "true", "Permit use of TPIDRRO_EL0 for the TLS base">;
959
960//===----------------------------------------------------------------------===//
961// Control codegen mitigation against Straight Line Speculation vulnerability.
962//===----------------------------------------------------------------------===//
963
964def FeatureHardenSlsRetBr : SubtargetFeature<"harden-sls-retbr",
965  "HardenSlsRetBr", "true",
966  "Harden against straight line speculation across RET and BR instructions">;
967def FeatureHardenSlsBlr : SubtargetFeature<"harden-sls-blr",
968  "HardenSlsBlr", "true",
969  "Harden against straight line speculation across BLR instructions">;
970def FeatureHardenSlsNoComdat : SubtargetFeature<"harden-sls-nocomdat",
971  "HardenSlsNoComdat", "true",
972  "Generate thunk code for SLS mitigation in the normal text section">;
973
974
975// Only intended to be used by disassemblers.
976def FeatureAll
977    : SubtargetFeature<"all", "IsAll", "true", "Enable all instructions">;
978