1//===-- RISCVFeatures.td - RISC-V Features and Extensions --*- 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// RISC-V subtarget features and instruction predicates.
11//===----------------------------------------------------------------------===//
12
13def FeatureStdExtZicsr
14    : SubtargetFeature<"zicsr", "HasStdExtZicsr", "true",
15                       "'zicsr' (CSRs)">;
16def HasStdExtZicsr : Predicate<"Subtarget->hasStdExtZicsr()">,
17                                AssemblerPredicate<(all_of FeatureStdExtZicsr),
18                                "'Zicsr' (CSRs)">;
19
20def FeatureStdExtM
21    : SubtargetFeature<"m", "HasStdExtM", "true",
22                       "'M' (Integer Multiplication and Division)">;
23def HasStdExtM : Predicate<"Subtarget->hasStdExtM()">,
24                           AssemblerPredicate<(all_of FeatureStdExtM),
25                           "'M' (Integer Multiplication and Division)">;
26
27def FeatureStdExtZmmul
28    : SubtargetFeature<"zmmul", "HasStdExtZmmul", "true",
29                       "'Zmmul' (Integer Multiplication)">;
30
31def HasStdExtMOrZmmul
32    : Predicate<"Subtarget->hasStdExtM() || Subtarget->hasStdExtZmmul()">,
33                AssemblerPredicate<(any_of FeatureStdExtM, FeatureStdExtZmmul),
34                                   "'M' (Integer Multiplication and Division) or "
35                                   "'Zmmul' (Integer Multiplication)">;
36
37def FeatureStdExtA
38    : SubtargetFeature<"a", "HasStdExtA", "true",
39                       "'A' (Atomic Instructions)">;
40def HasStdExtA : Predicate<"Subtarget->hasStdExtA()">,
41                           AssemblerPredicate<(all_of FeatureStdExtA),
42                           "'A' (Atomic Instructions)">;
43
44def FeatureStdExtF
45    : SubtargetFeature<"f", "HasStdExtF", "true",
46                       "'F' (Single-Precision Floating-Point)",
47                       [FeatureStdExtZicsr]>;
48def HasStdExtF : Predicate<"Subtarget->hasStdExtF()">,
49                           AssemblerPredicate<(all_of FeatureStdExtF),
50                           "'F' (Single-Precision Floating-Point)">;
51
52def FeatureStdExtD
53    : SubtargetFeature<"d", "HasStdExtD", "true",
54                       "'D' (Double-Precision Floating-Point)",
55                       [FeatureStdExtF]>;
56def HasStdExtD : Predicate<"Subtarget->hasStdExtD()">,
57                           AssemblerPredicate<(all_of FeatureStdExtD),
58                           "'D' (Double-Precision Floating-Point)">;
59
60def FeatureStdExtH
61    : SubtargetFeature<"h", "HasStdExtH", "true",
62                       "'H' (Hypervisor)">;
63
64def HasStdExtH : Predicate<"Subtarget->hasStdExtH()">,
65                           AssemblerPredicate<(all_of FeatureStdExtH),
66                           "'H' (Hypervisor)">;
67
68def FeatureStdExtZihintpause
69    : SubtargetFeature<"zihintpause", "HasStdExtZihintpause", "true",
70                       "'Zihintpause' (Pause Hint)">;
71def HasStdExtZihintpause : Predicate<"Subtarget->hasStdExtZihintpause()">,
72                                     AssemblerPredicate<(all_of FeatureStdExtZihintpause),
73                                     "'Zihintpause' (Pause Hint)">;
74
75def FeatureStdExtZihintntl
76    : SubtargetFeature<"experimental-zihintntl", "HasStdExtZihintntl", "true",
77                       "'Zihintntl' (Non-Temporal Locality Hints)">;
78def HasStdExtZihintntl : Predicate<"Subtarget->hasStdExtZihintntl()">,
79                                    AssemblerPredicate<(all_of FeatureStdExtZihintntl),
80                                    "'Zihintntl' (Non-Temporal Locality Hints)">;
81
82def FeatureStdExtZifencei
83    : SubtargetFeature<"zifencei", "HasStdExtZifencei", "true",
84                       "'Zifencei' (fence.i)">;
85def HasStdExtZifencei : Predicate<"Subtarget->hasStdExtZifencei()">,
86                                   AssemblerPredicate<(all_of FeatureStdExtZifencei),
87                                   "'Zifencei' (fence.i)">;
88
89def FeatureStdExtZicntr
90    : SubtargetFeature<"zicntr", "HasStdExtZicntr", "true",
91                       "'Zicntr' (Base Counters and Timers)",
92                       [FeatureStdExtZicsr]>;
93
94def FeatureStdExtZihpm
95    : SubtargetFeature<"zihpm", "HasStdExtZihpm", "true",
96                       "'Zihpm' (Hardware Performance Counters)",
97                       [FeatureStdExtZicsr]>;
98
99def FeatureStdExtZfhmin
100    : SubtargetFeature<"zfhmin", "HasStdExtZfhmin", "true",
101                       "'Zfhmin' (Half-Precision Floating-Point Minimal)",
102                       [FeatureStdExtF]>;
103def HasStdExtZfhmin : Predicate<"Subtarget->hasStdExtZfhmin()">,
104                             AssemblerPredicate<(all_of FeatureStdExtZfhmin),
105                             "'Zfhmin' (Half-Precision Floating-Point Minimal)">;
106
107def FeatureStdExtZfh
108    : SubtargetFeature<"zfh", "HasStdExtZfh", "true",
109                       "'Zfh' (Half-Precision Floating-Point)",
110                       [FeatureStdExtF]>;
111def HasStdExtZfh : Predicate<"Subtarget->hasStdExtZfh()">,
112                             AssemblerPredicate<(all_of FeatureStdExtZfh),
113                             "'Zfh' (Half-Precision Floating-Point)">;
114def NoStdExtZfh : Predicate<"!Subtarget->hasStdExtZfh()">;
115
116def HasStdExtZfhOrZfhmin
117    : Predicate<"Subtarget->hasStdExtZfhOrZfhmin()">,
118                AssemblerPredicate<(any_of FeatureStdExtZfh, FeatureStdExtZfhmin),
119                                   "'Zfh' (Half-Precision Floating-Point) or "
120                                   "'Zfhmin' (Half-Precision Floating-Point Minimal)">;
121
122def FeatureStdExtZfinx
123    : SubtargetFeature<"zfinx", "HasStdExtZfinx", "true",
124                       "'Zfinx' (Float in Integer)",
125                       [FeatureStdExtZicsr]>;
126def HasStdExtZfinx : Predicate<"Subtarget->hasStdExtZfinx()">,
127                               AssemblerPredicate<(all_of FeatureStdExtZfinx),
128                               "'Zfinx' (Float in Integer)">;
129
130def FeatureStdExtZdinx
131    : SubtargetFeature<"zdinx", "HasStdExtZdinx", "true",
132                       "'Zdinx' (Double in Integer)",
133                       [FeatureStdExtZfinx]>;
134def HasStdExtZdinx : Predicate<"Subtarget->hasStdExtZdinx()">,
135                               AssemblerPredicate<(all_of FeatureStdExtZdinx),
136                               "'Zdinx' (Double in Integer)">;
137
138def FeatureStdExtZhinxmin
139    : SubtargetFeature<"zhinxmin", "HasStdExtZhinxmin", "true",
140                       "'Zhinxmin' (Half Float in Integer Minimal)",
141                       [FeatureStdExtZfinx]>;
142def HasStdExtZhinxmin : Predicate<"Subtarget->hasStdExtZhinxmin()">,
143                                  AssemblerPredicate<(all_of FeatureStdExtZhinxmin),
144                                  "'Zhinxmin' (Half Float in Integer Minimal)">;
145
146def FeatureStdExtZhinx
147    : SubtargetFeature<"zhinx", "HasStdExtZhinx", "true",
148                       "'Zhinx' (Half Float in Integer)",
149                       [FeatureStdExtZfinx]>;
150def HasStdExtZhinx : Predicate<"Subtarget->hasStdExtZhinx()">,
151                               AssemblerPredicate<(all_of FeatureStdExtZhinx),
152                               "'Zhinx' (Half Float in Integer)">;
153def NoStdExtZhinx : Predicate<"!Subtarget->hasStdExtZhinx()">;
154
155def HasStdExtZhinxOrZhinxmin
156    : Predicate<"Subtarget->hasStdExtZhinx() || Subtarget->hasStdExtZhinxmin()">,
157                AssemblerPredicate<(any_of FeatureStdExtZhinx, FeatureStdExtZhinxmin),
158                                   "'Zhinx' (Half Float in Integer) or "
159                                   "'Zhinxmin' (Half Float in Integer Minimal)">;
160
161def FeatureStdExtZfa
162    : SubtargetFeature<"experimental-zfa", "HasStdExtZfa", "true",
163                       "'Zfa' (Additional Floating-Point)",
164                       [FeatureStdExtF]>;
165def HasStdExtZfa : Predicate<"Subtarget->hasStdExtZfa()">,
166                             AssemblerPredicate<(all_of FeatureStdExtZfa),
167                             "'Zfa' (Additional Floating-Point)">;
168
169def FeatureStdExtC
170    : SubtargetFeature<"c", "HasStdExtC", "true",
171                       "'C' (Compressed Instructions)">;
172def HasStdExtC : Predicate<"Subtarget->hasStdExtC()">,
173                           AssemblerPredicate<(all_of FeatureStdExtC),
174                           "'C' (Compressed Instructions)">;
175
176def FeatureStdExtZba
177    : SubtargetFeature<"zba", "HasStdExtZba", "true",
178                       "'Zba' (Address Generation Instructions)">;
179def HasStdExtZba : Predicate<"Subtarget->hasStdExtZba()">,
180                             AssemblerPredicate<(all_of FeatureStdExtZba),
181                             "'Zba' (Address Generation Instructions)">;
182def NotHasStdExtZba : Predicate<"!Subtarget->hasStdExtZba()">;
183
184def FeatureStdExtZbb
185    : SubtargetFeature<"zbb", "HasStdExtZbb", "true",
186                       "'Zbb' (Basic Bit-Manipulation)">;
187def HasStdExtZbb : Predicate<"Subtarget->hasStdExtZbb()">,
188                             AssemblerPredicate<(all_of FeatureStdExtZbb),
189                             "'Zbb' (Basic Bit-Manipulation)">;
190
191def FeatureStdExtZbc
192    : SubtargetFeature<"zbc", "HasStdExtZbc", "true",
193                       "'Zbc' (Carry-Less Multiplication)">;
194def HasStdExtZbc : Predicate<"Subtarget->hasStdExtZbc()">,
195                             AssemblerPredicate<(all_of FeatureStdExtZbc),
196                             "'Zbc' (Carry-Less Multiplication)">;
197
198def FeatureStdExtZbs
199    : SubtargetFeature<"zbs", "HasStdExtZbs", "true",
200                       "'Zbs' (Single-Bit Instructions)">;
201def HasStdExtZbs : Predicate<"Subtarget->hasStdExtZbs()">,
202                             AssemblerPredicate<(all_of FeatureStdExtZbs),
203                             "'Zbs' (Single-Bit Instructions)">;
204
205def FeatureStdExtZbkb
206    : SubtargetFeature<"zbkb", "HasStdExtZbkb", "true",
207                       "'Zbkb' (Bitmanip instructions for Cryptography)">;
208def HasStdExtZbkb : Predicate<"Subtarget->hasStdExtZbkb()">,
209                             AssemblerPredicate<(all_of FeatureStdExtZbkb),
210                             "'Zbkb' (Bitmanip instructions for Cryptography)">;
211
212def FeatureStdExtZbkx
213    : SubtargetFeature<"zbkx", "HasStdExtZbkx", "true",
214                       "'Zbkx' (Crossbar permutation instructions)">;
215def HasStdExtZbkx : Predicate<"Subtarget->hasStdExtZbkx()">,
216                             AssemblerPredicate<(all_of FeatureStdExtZbkx),
217                             "'Zbkx' (Crossbar permutation instructions)">;
218
219def HasStdExtZbbOrZbkb
220    : Predicate<"Subtarget->hasStdExtZbb() || Subtarget->hasStdExtZbkb()">,
221                AssemblerPredicate<(any_of FeatureStdExtZbb, FeatureStdExtZbkb),
222                                   "'Zbb' (Basic Bit-Manipulation) or "
223                                   "'Zbkb' (Bitmanip instructions for Cryptography)">;
224
225// The Carry-less multiply subextension for cryptography is a subset of basic
226// carry-less multiply subextension. The former should be enabled if the latter
227// is enabled.
228def FeatureStdExtZbkc
229    : SubtargetFeature<"zbkc", "HasStdExtZbkc", "true",
230                       "'Zbkc' (Carry-less multiply instructions for "
231                       "Cryptography)">;
232def HasStdExtZbkc
233    : Predicate<"Subtarget->hasStdExtZbkc()">,
234                AssemblerPredicate<(all_of FeatureStdExtZbkc),
235                "'Zbkc' (Carry-less multiply instructions for Cryptography)">;
236
237def HasStdExtZbcOrZbkc
238    : Predicate<"Subtarget->hasStdExtZbc() || Subtarget->hasStdExtZbkc()">,
239                AssemblerPredicate<(any_of FeatureStdExtZbc, FeatureStdExtZbkc),
240                                   "'Zbc' (Carry-Less Multiplication) or "
241                                   "'Zbkc' (Carry-less multiply instructions "
242                                   "for Cryptography)">;
243
244def FeatureStdExtZknd
245    : SubtargetFeature<"zknd", "HasStdExtZknd", "true",
246                       "'Zknd' (NIST Suite: AES Decryption)">;
247def HasStdExtZknd : Predicate<"Subtarget->hasStdExtZknd()">,
248                              AssemblerPredicate<(all_of FeatureStdExtZknd),
249                              "'Zknd' (NIST Suite: AES Decryption)">;
250
251def FeatureStdExtZkne
252    : SubtargetFeature<"zkne", "HasStdExtZkne", "true",
253                       "'Zkne' (NIST Suite: AES Encryption)">;
254def HasStdExtZkne : Predicate<"Subtarget->hasStdExtZkne()">,
255                              AssemblerPredicate<(all_of FeatureStdExtZkne),
256                              "'Zkne' (NIST Suite: AES Encryption)">;
257
258// Some instructions belong to both Zknd and Zkne subextensions.
259// They should be enabled if either has been specified.
260def HasStdExtZkndOrZkne
261    : Predicate<"Subtarget->hasStdExtZknd() || Subtarget->hasStdExtZkne()">,
262                AssemblerPredicate<(any_of FeatureStdExtZknd, FeatureStdExtZkne),
263                                   "'Zknd' (NIST Suite: AES Decryption) or "
264                                   "'Zkne' (NIST Suite: AES Encryption)">;
265
266def FeatureStdExtZknh
267    : SubtargetFeature<"zknh", "HasStdExtZknh", "true",
268                       "'Zknh' (NIST Suite: Hash Function Instructions)">;
269def HasStdExtZknh : Predicate<"Subtarget->hasStdExtZknh()">,
270                             AssemblerPredicate<(all_of FeatureStdExtZknh),
271                             "'Zknh' (NIST Suite: Hash Function Instructions)">;
272
273def FeatureStdExtZksed
274    : SubtargetFeature<"zksed", "HasStdExtZksed", "true",
275                       "'Zksed' (ShangMi Suite: SM4 Block Cipher Instructions)">;
276def HasStdExtZksed : Predicate<"Subtarget->hasStdExtZksed()">,
277                             AssemblerPredicate<(all_of FeatureStdExtZksed),
278                             "'Zksed' (ShangMi Suite: SM4 Block Cipher Instructions)">;
279
280def FeatureStdExtZksh
281    : SubtargetFeature<"zksh", "HasStdExtZksh", "true",
282                       "'Zksh' (ShangMi Suite: SM3 Hash Function Instructions)">;
283def HasStdExtZksh : Predicate<"Subtarget->hasStdExtZksh()">,
284                              AssemblerPredicate<(all_of FeatureStdExtZksh),
285                              "'Zksh' (ShangMi Suite: SM3 Hash Function "
286                              "Instructions)">;
287
288def FeatureStdExtZkr
289    : SubtargetFeature<"zkr", "HasStdExtZkr", "true",
290                       "'Zkr' (Entropy Source Extension)">;
291def HasStdExtZkr : Predicate<"Subtarget->hasStdExtZkr()">,
292                             AssemblerPredicate<(all_of FeatureStdExtZkr),
293                             "'Zkr' (Entropy Source Extension)">;
294
295def FeatureStdExtZkn
296    : SubtargetFeature<"zkn", "HasStdExtZkn", "true",
297                       "'Zkn' (NIST Algorithm Suite)",
298                       [FeatureStdExtZbkb,
299                        FeatureStdExtZbkc,
300                        FeatureStdExtZbkx,
301                        FeatureStdExtZkne,
302                        FeatureStdExtZknd,
303                        FeatureStdExtZknh]>;
304
305def FeatureStdExtZks
306    : SubtargetFeature<"zks", "HasStdExtZks", "true",
307                       "'Zks' (ShangMi Algorithm Suite)",
308                       [FeatureStdExtZbkb,
309                        FeatureStdExtZbkc,
310                        FeatureStdExtZbkx,
311                        FeatureStdExtZksed,
312                        FeatureStdExtZksh]>;
313
314def FeatureStdExtZkt
315    : SubtargetFeature<"zkt", "HasStdExtZkt", "true",
316                       "'Zkt' (Data Independent Execution Latency)">;
317
318def FeatureStdExtZk
319    : SubtargetFeature<"zk", "HasStdExtZk", "true",
320                       "'Zk' (Standard scalar cryptography extension)",
321                       [FeatureStdExtZkn,
322                        FeatureStdExtZkr,
323                        FeatureStdExtZkt]>;
324
325def FeatureStdExtZca
326    : SubtargetFeature<"zca", "HasStdExtZca", "true",
327                       "'Zca' (part of the C extension, excluding compressed "
328                       "floating point loads/stores)">;
329
330def HasStdExtCOrZca
331    : Predicate<"Subtarget->hasStdExtCOrZca()">,
332                AssemblerPredicate<(any_of FeatureStdExtC, FeatureStdExtZca),
333                                   "'C' (Compressed Instructions) or "
334                                   "'Zca' (part of the C extension, excluding "
335                                   "compressed floating point loads/stores)">;
336
337def FeatureStdExtZcb
338    : SubtargetFeature<"zcb", "HasStdExtZcb", "true",
339                       "'Zcb' (Compressed basic bit manipulation instructions)",
340                       [FeatureStdExtZca]>;
341def HasStdExtZcb : Predicate<"Subtarget->hasStdExtZcb()">,
342                             AssemblerPredicate<(all_of FeatureStdExtZcb),
343                             "'Zcb' (Compressed basic bit manipulation instructions)">;
344
345def FeatureStdExtZcd
346    : SubtargetFeature<"zcd", "HasStdExtZcd", "true",
347                       "'Zcd' (Compressed Double-Precision Floating-Point Instructions)",
348                       [FeatureStdExtZca]>;
349
350def HasStdExtCOrZcd
351    : Predicate<"Subtarget->hasStdExtC() || Subtarget->hasStdExtZcd()">,
352                AssemblerPredicate<(any_of FeatureStdExtC, FeatureStdExtZcd),
353                                   "'C' (Compressed Instructions) or "
354                                   "'Zcd' (Compressed Double-Precision Floating-Point Instructions)">;
355
356def FeatureStdExtZcf
357    : SubtargetFeature<"zcf", "HasStdExtZcf", "true",
358                       "'Zcf' (Compressed Single-Precision Floating-Point Instructions)",
359                       [FeatureStdExtZca]>;
360
361def FeatureStdExtZcmp
362    : SubtargetFeature<"zcmp", "HasStdExtZcmp", "true",
363                       "'Zcmp' (sequenced instuctions for code-size reduction)",
364                       [FeatureStdExtZca]>;
365def HasStdExtZcmp : Predicate<"Subtarget->hasStdExtZcmp() && !Subtarget->hasStdExtC()">,
366                               AssemblerPredicate<(all_of FeatureStdExtZcmp),
367                               "'Zcmp' (sequenced instuctions for code-size reduction)">;
368
369def FeatureStdExtZcmt
370    : SubtargetFeature<"zcmt", "HasStdExtZcmt", "true",
371                       "'Zcmt' (table jump instuctions for code-size reduction)",
372                       [FeatureStdExtZca, FeatureStdExtZicsr]>;
373def HasStdExtZcmt : Predicate<"Subtarget->hasStdExtZcmt()">,
374                           AssemblerPredicate<(all_of FeatureStdExtZcmt),
375                           "'Zcmt' (table jump instuctions for code-size reduction)">;
376
377def FeatureStdExtZce
378    : SubtargetFeature<"zce", "HasStdExtZce", "true",
379                       "'Zce' (Compressed extensions for microcontrollers)",
380                       [FeatureStdExtZca, FeatureStdExtZcb, FeatureStdExtZcmp,
381                        FeatureStdExtZcmt]>;
382
383def HasStdExtCOrZcfOrZce
384    : Predicate<"Subtarget->hasStdExtC() || Subtarget->hasStdExtZcf() "
385                "Subtarget->hasStdExtZce()">,
386                AssemblerPredicate<(any_of FeatureStdExtC, FeatureStdExtZcf,
387                                           FeatureStdExtZce),
388                                   "'C' (Compressed Instructions) or "
389                                   "'Zcf' (Compressed Single-Precision Floating-Point Instructions)">;
390
391def FeatureNoRVCHints
392    : SubtargetFeature<"no-rvc-hints", "EnableRVCHintInstrs", "false",
393                       "Disable RVC Hint Instructions.">;
394def HasRVCHints : Predicate<"Subtarget->enableRVCHintInstrs()">,
395                  AssemblerPredicate<(all_of(not FeatureNoRVCHints)),
396                                      "RVC Hint Instructions">;
397
398def FeatureStdExtZvl32b : SubtargetFeature<"zvl32b", "ZvlLen", "32",
399                                           "'Zvl' (Minimum Vector Length) 32">;
400
401foreach i = { 6-16 } in {
402  defvar I = !shl(1, i);
403  def FeatureStdExtZvl#I#b :
404      SubtargetFeature<"zvl"#I#"b", "ZvlLen", !cast<string>(I),
405                       "'Zvl' (Minimum Vector Length) "#I,
406                       [!cast<SubtargetFeature>("FeatureStdExtZvl"#!srl(I, 1)#"b")]>;
407}
408
409def FeatureStdExtZve32x
410    : SubtargetFeature<"zve32x", "HasStdExtZve32x", "true",
411                       "'Zve32x' (Vector Extensions for Embedded Processors "
412                       "with maximal 32 EEW)",
413                       [FeatureStdExtZicsr, FeatureStdExtZvl32b]>;
414
415def FeatureStdExtZve32f
416    : SubtargetFeature<"zve32f", "HasStdExtZve32f", "true",
417                       "'Zve32f' (Vector Extensions for Embedded Processors "
418                       "with maximal 32 EEW and F extension)",
419                       [FeatureStdExtZve32x, FeatureStdExtF]>;
420
421def FeatureStdExtZve64x
422    : SubtargetFeature<"zve64x", "HasStdExtZve64x", "true",
423                       "'Zve64x' (Vector Extensions for Embedded Processors "
424                       "with maximal 64 EEW)",
425                       [FeatureStdExtZve32x, FeatureStdExtZvl64b]>;
426
427def FeatureStdExtZve64f
428    : SubtargetFeature<"zve64f", "HasStdExtZve64f", "true",
429                       "'Zve64f' (Vector Extensions for Embedded Processors "
430                       "with maximal 64 EEW and F extension)",
431                       [FeatureStdExtZve32f, FeatureStdExtZve64x]>;
432
433def FeatureStdExtZve64d
434    : SubtargetFeature<"zve64d", "HasStdExtZve64d", "true",
435                       "'Zve64d' (Vector Extensions for Embedded Processors "
436                       "with maximal 64 EEW, F and D extension)",
437                       [FeatureStdExtZve64f, FeatureStdExtD]>;
438
439def FeatureStdExtV
440    : SubtargetFeature<"v", "HasStdExtV", "true",
441                       "'V' (Vector Extension for Application Processors)",
442                       [FeatureStdExtZvl128b, FeatureStdExtZve64d]>;
443
444def HasVInstructions    : Predicate<"Subtarget->hasVInstructions()">,
445      AssemblerPredicate<
446          (any_of FeatureStdExtZve32x),
447          "'V' (Vector Extension for Application Processors), 'Zve32x' or "
448          "'Zve64x' (Vector Extensions for Embedded Processors)">;
449def HasVInstructionsI64 : Predicate<"Subtarget->hasVInstructionsI64()">,
450      AssemblerPredicate<
451          (any_of FeatureStdExtZve64x),
452          "'V' (Vector Extension for Application Processors) or 'Zve64x' "
453          "(Vector Extensions for Embedded Processors)">;
454def HasVInstructionsAnyF : Predicate<"Subtarget->hasVInstructionsAnyF()">,
455      AssemblerPredicate<
456          (any_of FeatureStdExtZve32f),
457          "'V' (Vector Extension for Application Processors), 'Zve32f', "
458          "'Zve64f' or 'Zve64d' (Vector Extensions for Embedded Processors)">;
459
460def HasVInstructionsF64 : Predicate<"Subtarget->hasVInstructionsF64()">;
461
462def HasVInstructionsFullMultiply : Predicate<"Subtarget->hasVInstructionsFullMultiply()">;
463
464def FeatureStdExtZvfbfmin
465    : SubtargetFeature<"experimental-zvfbfmin", "HasStdExtZvfbfmin", "true",
466                       "'Zvbfmin' (Vector BF16 Converts)",
467                       [FeatureStdExtZve32f]>;
468def HasStdExtZvfbfmin : Predicate<"Subtarget->hasStdExtZvfbfmin()">,
469                                  AssemblerPredicate<(all_of FeatureStdExtZvfbfmin),
470                                  "'Zvfbfmin' (Vector BF16 Converts)">;
471
472def FeatureStdExtZvfbfwma
473    : SubtargetFeature<"experimental-zvfbfwma", "HasStdExtZvfbfwma", "true",
474                       "'Zvfbfwma' (Vector BF16 widening mul-add)",
475                       [FeatureStdExtZve32f]>;
476def HasStdExtZvfbfwma : Predicate<"Subtarget->hasStdExtZvfbfwma()">,
477                                  AssemblerPredicate<(all_of FeatureStdExtZvfbfwma),
478                                  "'Zvfbfwma' (Vector BF16 widening mul-add)">;
479
480def FeatureStdExtZvfh
481    : SubtargetFeature<"zvfh", "HasStdExtZvfh", "true",
482                       "'Zvfh' (Vector Half-Precision Floating-Point)",
483                       [FeatureStdExtZve32f, FeatureStdExtZfhmin]>;
484
485def HasVInstructionsF16 : Predicate<"Subtarget->hasVInstructionsF16()">;
486
487def HasStdExtZfhOrZvfh
488    : Predicate<"Subtarget->hasStdExtZfh() || Subtarget->hasStdExtZvfh()">,
489                AssemblerPredicate<(any_of FeatureStdExtZfh, FeatureStdExtZvfh),
490                                   "'Zfh' (Half-Precision Floating-Point) or "
491                                   "'Zvfh' (Vector Half-Precision Floating-Point)">;
492
493def FeatureStdExtZicbom
494    : SubtargetFeature<"zicbom", "HasStdExtZicbom", "true",
495                       "'Zicbom' (Cache-Block Management Instructions)">;
496def HasStdExtZicbom : Predicate<"Subtarget->hasStdExtZicbom()">,
497                                AssemblerPredicate<(all_of FeatureStdExtZicbom),
498                                "'Zicbom' (Cache-Block Management Instructions)">;
499
500def FeatureStdExtZicboz
501    : SubtargetFeature<"zicboz", "HasStdExtZicboz", "true",
502                       "'Zicboz' (Cache-Block Zero Instructions)">;
503def HasStdExtZicboz : Predicate<"Subtarget->hasStdExtZicboz()">,
504                                AssemblerPredicate<(all_of FeatureStdExtZicboz),
505                                "'Zicboz' (Cache-Block Zero Instructions)">;
506
507def FeatureStdExtZicbop
508    : SubtargetFeature<"zicbop", "HasStdExtZicbop", "true",
509                       "'Zicbop' (Cache-Block Prefetch Instructions)">;
510def HasStdExtZicbop : Predicate<"Subtarget->hasStdExtZicbop()">,
511                                AssemblerPredicate<(all_of FeatureStdExtZicbop),
512                                "'Zicbop' (Cache-Block Prefetch Instructions)">;
513
514def FeatureStdExtSvnapot
515    : SubtargetFeature<"svnapot", "HasStdExtSvnapot", "true",
516                       "'Svnapot' (NAPOT Translation Contiguity)">;
517
518def FeatureStdExtSvpbmt
519    : SubtargetFeature<"svpbmt", "HasStdExtSvpbmt", "true",
520                       "'Svpbmt' (Page-Based Memory Types)">;
521
522def FeatureStdExtSvinval
523    : SubtargetFeature<"svinval", "HasStdExtSvinval", "true",
524                       "'Svinval' (Fine-Grained Address-Translation Cache Invalidation)">;
525def HasStdExtSvinval : Predicate<"Subtarget->hasStdExtSvinval()">,
526                                AssemblerPredicate<(all_of FeatureStdExtSvinval),
527                                "'Svinval' (Fine-Grained Address-Translation Cache Invalidation)">;
528
529def FeatureStdExtZtso
530    : SubtargetFeature<"experimental-ztso", "HasStdExtZtso", "true",
531                       "'Ztso' (Memory Model - Total Store Order)">;
532def HasStdExtZtso : Predicate<"Subtarget->hasStdExtZTso()">,
533                              AssemblerPredicate<(all_of FeatureStdExtZtso),
534                              "'Ztso' (Memory Model - Total Store Order)">;
535
536def FeatureStdExtZawrs : SubtargetFeature<"zawrs", "HasStdExtZawrs", "true",
537                                          "'Zawrs' (Wait on Reservation Set)">;
538def HasStdExtZawrs : Predicate<"Subtarget->hasStdExtZawrs()">,
539                               AssemblerPredicate<(all_of FeatureStdExtZawrs),
540                               "'Zawrs' (Wait on Reservation Set)">;
541
542def FeatureStdExtZvbb
543    : SubtargetFeature<"experimental-zvbb", "HasStdExtZvbb", "true",
544                       "'Zvbb' (Vector Bit-manipulation used in Cryptography)">;
545def HasStdExtZvbb : Predicate<"Subtarget->hasStdExtZvbb()">,
546                              AssemblerPredicate<(all_of FeatureStdExtZvbb),
547                              "'Zvbb' (Vector Bit-manipulation used in Cryptography)">;
548
549def FeatureStdExtZvbc
550    : SubtargetFeature<"experimental-zvbc", "HasStdExtZvbc", "true",
551                       "'Zvbc' (Vector Carryless Multiplication)">;
552def HasStdExtZvbc : Predicate<"Subtarget->hasStdExtZvbc()">,
553                              AssemblerPredicate<(all_of FeatureStdExtZvbc),
554                              "'Zvbc' (Vector Carryless Multiplication)">;
555
556def FeatureStdExtZvkg
557    : SubtargetFeature<"experimental-zvkg", "HasStdExtZvkg", "true",
558                       "'Zvkg' (Vector GCM instructions for Cryptography)">;
559def HasStdExtZvkg : Predicate<"Subtarget->hasStdExtZvkg()">,
560                              AssemblerPredicate<(all_of FeatureStdExtZvkg),
561                              "'Zvkg' (Vector GCM instructions for Cryptography)">;
562
563def FeatureStdExtZvkn
564    : SubtargetFeature<"experimental-zvkn", "HasStdExtZvkn", "true",
565                       "This extension is shorthand for the following set of "
566                       "other extensions: Zvkned, Zvknhb, Zvbb, Zvbc, and Zvkt.">;
567
568def FeatureStdExtZvknc
569    : SubtargetFeature<"experimental-zvknc", "HasStdExtZvknc", "true",
570                       "This extension is shorthand for the following set of "
571                       "other extensions: Zvkn and Zvbc.">;
572
573def FeatureStdExtZvkned
574    : SubtargetFeature<"experimental-zvkned", "HasStdExtZvkned", "true",
575                       "'Zvkned' (Vector AES Encryption & Decryption (Single Round))">;
576def HasStdExtZvkned : Predicate<"Subtarget->hasStdExtZvkned()">,
577                                AssemblerPredicate<(all_of FeatureStdExtZvkned),
578                                "'Zvkned' (Vector AES Encryption & Decryption (Single Round))">;
579
580def FeatureStdExtZvkng
581    : SubtargetFeature<"experimental-zvkng", "HasStdExtZvkng", "true",
582                       "This extension is shorthand for the following set of "
583                       "other extensions: Zvkn and Zvkg.">;
584
585def FeatureStdExtZvknha
586    : SubtargetFeature<"experimental-zvknha", "HasStdExtZvknha", "true",
587                       "'Zvknha' (Vector SHA-2 (SHA-256 only))">;
588
589def FeatureStdExtZvknhb
590    : SubtargetFeature<"experimental-zvknhb", "HasStdExtZvknhb", "true",
591                       "'Zvknhb' (Vector SHA-2 (SHA-256 and SHA-512))",
592                       [FeatureStdExtZvknha]>;
593def HasStdExtZvknha : Predicate<"Subtarget->hasStdExtZvknha()">,
594                                AssemblerPredicate<(all_of FeatureStdExtZvknha),
595                                "'Zvknha' (Vector SHA-2 (SHA-256 only))">;
596
597def FeatureStdExtZvks
598    : SubtargetFeature<"experimental-zvks", "HasStdExtZvks", "true",
599                       "This extension is shorthand for the following set of "
600                       "other extensions: Zvksed, Zvksh, Zvbb, Zvbc, and Zvkt.">;
601
602def FeatureStdExtZvksc
603    : SubtargetFeature<"experimental-zvksc", "HasStdExtZvksc", "true",
604                       "This extension is shorthand for the following set of "
605                       "other extensions: Zvks and Zvbc.">;
606
607def FeatureStdExtZvksed
608    : SubtargetFeature<"experimental-zvksed", "HasStdExtZvksed", "true",
609                       "'Zvksed' (SM4 Block Cipher Instructions)">;
610def HasStdExtZvksed : Predicate<"Subtarget->hasStdExtZvksed()">,
611                                AssemblerPredicate<(all_of FeatureStdExtZvksed),
612                                "'Zvksed' (SM4 Block Cipher Instructions)">;
613
614def FeatureStdExtZvksg
615    : SubtargetFeature<"experimental-zvksg", "HasStdExtZvksg", "true",
616                       "This extension is shorthand for the following set of "
617                       "other extensions: Zvks and Zvkg.">;
618
619def FeatureStdExtZvksh
620    : SubtargetFeature<"experimental-zvksh", "HasStdExtZvksh", "true",
621                       "'Zvksh' (SM3 Hash Function Instructions)">;
622def HasStdExtZvksh : Predicate<"Subtarget->hasStdExtZvksh()">,
623                               AssemblerPredicate<(all_of FeatureStdExtZvksh),
624                               "'Zvksh' (SM3 Hash Function Instructions)">;
625
626def FeatureStdExtZvkt
627    : SubtargetFeature<"experimental-zvkt", "HasStdExtZvkt", "true",
628                       "'Zvkt' (Vector Data-Independent Execution Latency)">;
629
630def FeatureStdExtZicond
631    : SubtargetFeature<"experimental-zicond", "HasStdExtZicond", "true",
632                       "'Zicond' (Integer Conditional Operations)">;
633def HasStdExtZicond : Predicate<"Subtarget->hasStdExtZicond()">,
634                                AssemblerPredicate<(all_of FeatureStdExtZicond),
635                                "'Zicond' (Integer Conditional Operations)">;
636
637def FeatureStdExtSmaia
638    : SubtargetFeature<"experimental-smaia", "HasStdExtSmaia", "true",
639                       "'Smaia' (Smaia encompasses all added CSRs and all "
640                       "modifications to interrupt response behavior that the "
641                       "AIA specifies for a hart, over all privilege levels.)",
642                       []>;
643
644def FeatureStdExtSsaia
645    : SubtargetFeature<"experimental-ssaia", "HasStdExtSsaia", "true",
646                       "'Ssaia' (Ssaia is essentially the same as Smaia except "
647                       "excluding the machine-level CSRs and behavior not "
648                       "directly visible to supervisor level.)", []>;
649
650def FeatureStdExtZfbfmin
651    : SubtargetFeature<"experimental-zfbfmin", "HasStdExtZfbfmin", "true",
652                       "'Zfbfmin' (Scalar BF16 Converts)",
653                       [FeatureStdExtF]>;
654def HasStdExtZfbfmin : Predicate<"Subtarget->hasStdExtZfbfmin()">,
655                                 AssemblerPredicate<(all_of FeatureStdExtZfbfmin),
656                                 "'Zfbfmin' (Scalar BF16 Converts)">;
657
658def HasHalfFPLoadStoreMove
659    : Predicate<"Subtarget->hasHalfFPLoadStoreMove()">,
660                AssemblerPredicate<(any_of FeatureStdExtZfh, FeatureStdExtZfhmin,
661                                    FeatureStdExtZfbfmin, FeatureStdExtZvfbfwma),
662                                    "'Zfh' (Half-Precision Floating-Point) or "
663                                    "'Zfhmin' (Half-Precision Floating-Point Minimal) or "
664                                    "'Zfbfmin' (Scalar BF16 Converts) or "
665                                    "'Zvfbfwma' (Vector BF16 widening mul-add)">;
666
667def FeatureStdExtZacas
668    : SubtargetFeature<"experimental-zacas", "HasStdExtZacas", "true",
669                       "'Zacas' (Atomic Compare-And-Swap Instructions)">;
670def HasStdExtZacas : Predicate<"Subtarget->hasStdExtZacas()">,
671                               AssemblerPredicate<(all_of FeatureStdExtZacas),
672                               "'Zacas' (Atomic Compare-And-Swap Instructions)">;
673
674//===----------------------------------------------------------------------===//
675// Vendor extensions
676//===----------------------------------------------------------------------===//
677
678def FeatureVendorXVentanaCondOps
679    : SubtargetFeature<"xventanacondops", "HasVendorXVentanaCondOps", "true",
680                       "'XVentanaCondOps' (Ventana Conditional Ops)">;
681def HasVendorXVentanaCondOps : Predicate<"Subtarget->hasVendorXVentanaCondOps()">,
682                                AssemblerPredicate<(all_of FeatureVendorXVentanaCondOps),
683                                "'XVentanaCondOps' (Ventana Conditional Ops)">;
684
685def FeatureVendorXTHeadBa
686    : SubtargetFeature<"xtheadba", "HasVendorXTHeadBa", "true",
687                       "'xtheadba' (T-Head address calculation instructions)">;
688def HasVendorXTHeadBa : Predicate<"Subtarget->hasVendorXTHeadBa()">,
689                                  AssemblerPredicate<(all_of FeatureVendorXTHeadBa),
690                                  "'xtheadba' (T-Head address calculation instructions)">;
691
692def FeatureVendorXTHeadBb
693    : SubtargetFeature<"xtheadbb", "HasVendorXTHeadBb", "true",
694                       "'xtheadbb' (T-Head basic bit-manipulation instructions)">;
695def HasVendorXTHeadBb : Predicate<"Subtarget->hasVendorXTHeadBb()">,
696                                  AssemblerPredicate<(all_of FeatureVendorXTHeadBb),
697                                  "'xtheadbb' (T-Head basic bit-manipulation instructions)">;
698
699def FeatureVendorXTHeadBs
700    : SubtargetFeature<"xtheadbs", "HasVendorXTHeadBs", "true",
701                       "'xtheadbs' (T-Head single-bit instructions)">;
702def HasVendorXTHeadBs : Predicate<"Subtarget->hasVendorXTHeadBs()">,
703                                  AssemblerPredicate<(all_of FeatureVendorXTHeadBs),
704                                  "'xtheadbs' (T-Head single-bit instructions)">;
705
706def FeatureVendorXTHeadCondMov
707    : SubtargetFeature<"xtheadcondmov", "HasVendorXTHeadCondMov", "true",
708                       "'xtheadcondmov' (T-Head conditional move instructions)">;
709def HasVendorXTHeadCondMov : Predicate<"Subtarget->hasVendorXTHeadCondMov()">,
710                                       AssemblerPredicate<(all_of FeatureVendorXTHeadCondMov),
711                                       "'xtheadcondmov' (T-Head conditional move instructions)">;
712
713def FeatureVendorXTHeadCmo
714    : SubtargetFeature<"xtheadcmo", "HasVendorXTHeadCmo", "true",
715                       "'xtheadcmo' (T-Head cache management instructions)">;
716def HasVendorXTHeadCmo : Predicate<"Subtarget->hasVendorXTHeadCmo()">,
717                                   AssemblerPredicate<(all_of FeatureVendorXTHeadCmo),
718                                   "'xtheadcmo' (T-Head cache management instructions)">;
719
720def FeatureVendorXTHeadFMemIdx
721    : SubtargetFeature<"xtheadfmemidx", "HasVendorXTHeadFMemIdx", "true",
722                       "'xtheadfmemidx' (T-Head FP Indexed Memory Operations)",
723                       [FeatureStdExtF]>;
724def HasVendorXTHeadFMemIdx : Predicate<"Subtarget->hasVendorXTHeadFMemIdx()">,
725                                       AssemblerPredicate<(all_of FeatureVendorXTHeadFMemIdx),
726                                       "'xtheadfmemidx' (T-Head FP Indexed Memory Operations)">;
727
728def FeatureVendorXTHeadMac
729    : SubtargetFeature<"xtheadmac", "HasVendorXTHeadMac", "true",
730                       "'xtheadmac' (T-Head Multiply-Accumulate Instructions)">;
731def HasVendorXTHeadMac : Predicate<"Subtarget->hasVendorXTHeadMac()">,
732                                   AssemblerPredicate<(all_of FeatureVendorXTHeadMac),
733                                   "'xtheadmac' (T-Head Multiply-Accumulate Instructions)">;
734
735def FeatureVendorXTHeadMemIdx
736    : SubtargetFeature<"xtheadmemidx", "HasVendorXTHeadMemIdx", "true",
737                       "'xtheadmemidx' (T-Head Indexed Memory Operations)">;
738def HasVendorXTHeadMemIdx : Predicate<"Subtarget->hasVendorXTHeadMemIdx()">,
739                                      AssemblerPredicate<(all_of FeatureVendorXTHeadMemIdx),
740                                      "'xtheadmemidx' (T-Head Indexed Memory Operations)">;
741
742def FeatureVendorXTHeadMemPair
743    : SubtargetFeature<"xtheadmempair", "HasVendorXTHeadMemPair", "true",
744                       "'xtheadmempair' (T-Head two-GPR Memory Operations)">;
745def HasVendorXTHeadMemPair : Predicate<"Subtarget->hasVendorXTHeadMemPair()">,
746                                    AssemblerPredicate<(all_of FeatureVendorXTHeadMemPair),
747                                    "'xtheadmempair' (T-Head two-GPR Memory Operations)">;
748
749def FeatureVendorXTHeadSync
750    : SubtargetFeature<"xtheadsync", "HasVendorXTHeadSync", "true",
751                       "'xtheadsync' (T-Head multicore synchronization instructions)">;
752def HasVendorXTHeadSync : Predicate<"Subtarget->hasVendorXTHeadSync()">,
753                                    AssemblerPredicate<(all_of FeatureVendorXTHeadSync),
754                                    "'xtheadsync' (T-Head multicore synchronization instructions)">;
755
756def FeatureVendorXTHeadVdot
757    : SubtargetFeature<"xtheadvdot", "HasVendorXTHeadVdot", "true",
758                       "'xtheadvdot' (T-Head Vector Extensions for Dot)",
759                       [FeatureStdExtV]>;
760def HasVendorXTHeadVdot : Predicate<"Subtarget->hasVendorXTHeadVdot()">,
761                                    AssemblerPredicate<(all_of FeatureVendorXTHeadVdot),
762                                    "'xtheadvdot' (T-Head Vector Extensions for Dot)">;
763
764def FeatureVendorXSfvcp
765    : SubtargetFeature<"xsfvcp", "HasVendorXSfvcp", "true",
766                       "'XSfvcp' (SiFive Custom Vector Coprocessor Interface Instructions)",
767                       [FeatureStdExtZve32x]>;
768def HasVendorXSfvcp : Predicate<"Subtarget->hasVendorXSfvcp()">,
769                                AssemblerPredicate<(all_of FeatureVendorXSfvcp),
770                                "'XSfvcp' (SiFive Custom Vector Coprocessor Interface Instructions)">;
771
772def FeatureVendorXSfcie
773    : SubtargetFeature<"xsfcie", "HasVendorXSfcie", "true",
774                       "'XSfcie' (SiFive Custom Instruction Extension SCIE.)">;
775def HasVendorXSfcie : Predicate<"Subtarget->hasVendorXSfcie()">,
776                        AssemblerPredicate<(all_of FeatureVendorXSfcie),
777                        "'XSfcie' (SiFive Custom Instruction Extension SCIE.)">;
778
779def FeatureVendorXCVbitmanip
780    : SubtargetFeature<"xcvbitmanip", "HasVendorXCVbitmanip", "true",
781                       "'XCVbitmanip' (CORE-V Bit Manipulation)">;
782def HasVendorXCVbitmanip : Predicate<"Subtarget->hasVendorXCVbitmanip()">,
783                                AssemblerPredicate<(all_of FeatureVendorXCVbitmanip),
784                                "'XCVbitmanip' (CORE-V Bit Manipulation)">;
785
786def FeatureVendorXCVmac
787    : SubtargetFeature<"xcvmac", "HasVendorXCVmac", "true",
788                       "'XCVmac' (CORE-V Multiply-Accumulate)">;
789def HasVendorXCVmac : Predicate<"Subtarget->hasVendorXCVmac()">,
790                                AssemblerPredicate<(all_of FeatureVendorXCVmac),
791                                "'XCVmac' (CORE-V Multiply-Accumulate)">;
792
793//===----------------------------------------------------------------------===//
794// LLVM specific features and extensions
795//===----------------------------------------------------------------------===//
796
797// Feature32Bit exists to mark CPUs that support RV32 to distinquish them from
798// tuning CPU names.
799def Feature32Bit
800    : SubtargetFeature<"32bit", "IsRV32", "true", "Implements RV32">;
801def Feature64Bit
802    : SubtargetFeature<"64bit", "IsRV64", "true", "Implements RV64">;
803def IsRV64 : Predicate<"Subtarget->is64Bit()">,
804                       AssemblerPredicate<(all_of Feature64Bit),
805                                         "RV64I Base Instruction Set">;
806def IsRV32 : Predicate<"!Subtarget->is64Bit()">,
807                       AssemblerPredicate<(all_of (not Feature64Bit)),
808                                          "RV32I Base Instruction Set">;
809
810defvar RV32 = DefaultMode;
811def RV64           : HwMode<"+64bit", [IsRV64]>;
812
813def FeatureRVE
814    : SubtargetFeature<"e", "IsRVE", "true",
815                       "Implements RV{32,64}E (provides 16 rather than 32 GPRs)">;
816def IsRVE : Predicate<"Subtarget->isRVE()">,
817                        AssemblerPredicate<(all_of FeatureRVE)>;
818
819def FeatureRelax
820    : SubtargetFeature<"relax", "EnableLinkerRelax", "true",
821                       "Enable Linker relaxation.">;
822
823foreach i = {1-31} in
824  def FeatureReserveX#i :
825      SubtargetFeature<"reserve-x"#i, "UserReservedRegister[RISCV::X"#i#"]",
826                       "true", "Reserve X"#i>;
827
828def FeatureSaveRestore : SubtargetFeature<"save-restore", "EnableSaveRestore",
829                                          "true", "Enable save/restore.">;
830
831def FeatureTrailingSeqCstFence : SubtargetFeature<"seq-cst-trailing-fence",
832                                          "EnableSeqCstTrailingFence",
833                                          "true",
834                                          "Enable trailing fence for seq-cst store.">;
835
836def FeatureUnalignedScalarMem
837   : SubtargetFeature<"unaligned-scalar-mem", "EnableUnalignedScalarMem",
838                      "true", "Has reasonably performant unaligned scalar "
839                      "loads and stores">;
840
841def FeatureUnalignedVectorMem
842   : SubtargetFeature<"unaligned-vector-mem", "EnableUnalignedVectorMem",
843                      "true", "Has reasonably performant unaligned vector "
844                      "loads and stores">;
845
846def TuneNoOptimizedZeroStrideLoad
847   : SubtargetFeature<"no-optimized-zero-stride-load", "HasOptimizedZeroStrideLoad",
848                      "false", "Hasn't optimized (perform fewer memory operations)"
849                      "zero-stride vector load">;
850
851// Some vector hardware implementations do not process all VLEN bits in parallel
852// and instead split over multiple cycles. DLEN refers to the datapath width
853// that can be done in parallel.
854def TuneDLenFactor2
855   : SubtargetFeature<"dlen-factor-2", "DLenFactor2", "true",
856                      "Vector unit DLEN(data path width) is half of VLEN">;
857
858def TuneLUIADDIFusion
859    : SubtargetFeature<"lui-addi-fusion", "HasLUIADDIFusion",
860                       "true", "Enable LUI+ADDI macrofusion">;
861
862def TuneNoDefaultUnroll
863    : SubtargetFeature<"no-default-unroll", "EnableDefaultUnroll", "false",
864                       "Disable default unroll preference.">;
865
866// SiFive 7 is able to fuse integer ALU operations with a preceding branch
867// instruction.
868def TuneShortForwardBranchOpt
869    : SubtargetFeature<"short-forward-branch-opt", "HasShortForwardBranchOpt",
870                       "true", "Enable short forward branch optimization">;
871def HasShortForwardBranchOpt : Predicate<"Subtarget->hasShortForwardBranchOpt()">;
872def NoShortForwardBranchOpt : Predicate<"!Subtarget->hasShortForwardBranchOpt()">;
873
874def TuneSiFive7 : SubtargetFeature<"sifive7", "RISCVProcFamily", "SiFive7",
875                                   "SiFive 7-Series processors",
876                                   [TuneNoDefaultUnroll,
877                                    TuneShortForwardBranchOpt]>;
878
879// Assume that lock-free native-width atomics are available, even if the target
880// and operating system combination would not usually provide them. The user
881// is responsible for providing any necessary __sync implementations. Code
882// built with this feature is not ABI-compatible with code built without this
883// feature, if atomic variables are exposed across the ABI boundary.
884def FeatureForcedAtomics : SubtargetFeature<
885    "forced-atomics", "HasForcedAtomics", "true",
886    "Assume that lock-free native-width atomics are available">;
887def HasAtomicLdSt
888    : Predicate<"Subtarget->hasStdExtA() || Subtarget->hasForcedAtomics()">;
889
890def FeatureTaggedGlobals : SubtargetFeature<"tagged-globals",
891    "AllowTaggedGlobals",
892    "true", "Use an instruction sequence for taking the address of a global "
893    "that allows a memory tag in the upper address bits">;
894