RISCVFeatures.td 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. //===-- RISCVFeatures.td - RISCV 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. // RISC-V subtarget features and instruction predicates.
  10. //===----------------------------------------------------------------------===//
  11. def FeatureStdExtM
  12. : SubtargetFeature<"m", "HasStdExtM", "true",
  13. "'M' (Integer Multiplication and Division)">;
  14. def HasStdExtM : Predicate<"Subtarget->hasStdExtM()">,
  15. AssemblerPredicate<(all_of FeatureStdExtM),
  16. "'M' (Integer Multiplication and Division)">;
  17. def FeatureStdExtZmmul
  18. : SubtargetFeature<"zmmul", "HasStdExtZmmul", "true",
  19. "'Zmmul' (Integer Multiplication)">;
  20. def HasStdExtMOrZmmul
  21. : Predicate<"Subtarget->hasStdExtM() || Subtarget->hasStdExtZmmul()">,
  22. AssemblerPredicate<(any_of FeatureStdExtM, FeatureStdExtZmmul),
  23. "'M' (Integer Multiplication and Division) or "
  24. "'Zmmul' (Integer Multiplication)">;
  25. def FeatureStdExtA
  26. : SubtargetFeature<"a", "HasStdExtA", "true",
  27. "'A' (Atomic Instructions)">;
  28. def HasStdExtA : Predicate<"Subtarget->hasStdExtA()">,
  29. AssemblerPredicate<(all_of FeatureStdExtA),
  30. "'A' (Atomic Instructions)">;
  31. def FeatureStdExtF
  32. : SubtargetFeature<"f", "HasStdExtF", "true",
  33. "'F' (Single-Precision Floating-Point)">;
  34. def HasStdExtF : Predicate<"Subtarget->hasStdExtF()">,
  35. AssemblerPredicate<(all_of FeatureStdExtF),
  36. "'F' (Single-Precision Floating-Point)">;
  37. def FeatureStdExtD
  38. : SubtargetFeature<"d", "HasStdExtD", "true",
  39. "'D' (Double-Precision Floating-Point)",
  40. [FeatureStdExtF]>;
  41. def HasStdExtD : Predicate<"Subtarget->hasStdExtD()">,
  42. AssemblerPredicate<(all_of FeatureStdExtD),
  43. "'D' (Double-Precision Floating-Point)">;
  44. def FeatureStdExtH
  45. : SubtargetFeature<"h", "HasStdExtH", "true",
  46. "'H' (Hypervisor)">;
  47. def HasStdExtH : Predicate<"Subtarget->hasStdExtH()">,
  48. AssemblerPredicate<(all_of FeatureStdExtH),
  49. "'H' (Hypervisor)">;
  50. def FeatureStdExtZihintpause
  51. : SubtargetFeature<"zihintpause", "HasStdExtZihintpause", "true",
  52. "'zihintpause' (Pause Hint)">;
  53. def HasStdExtZihintpause : Predicate<"Subtarget->hasStdExtZihintpause()">,
  54. AssemblerPredicate<(all_of FeatureStdExtZihintpause),
  55. "'Zihintpause' (Pause Hint)">;
  56. def FeatureStdExtZihintntl
  57. : SubtargetFeature<"experimental-zihintntl", "HasStdExtZihintntl", "true",
  58. "'zihintntl' (Non-Temporal Locality Hints)">;
  59. def HasStdExtZihintntl : Predicate<"Subtarget->hasStdExtZihintntl()">,
  60. AssemblerPredicate<(all_of FeatureStdExtZihintntl),
  61. "'Zihintntl' (Non-Temporal Locality Hints)">;
  62. def FeatureStdExtZfhmin
  63. : SubtargetFeature<"zfhmin", "HasStdExtZfhmin", "true",
  64. "'Zfhmin' (Half-Precision Floating-Point Minimal)",
  65. [FeatureStdExtF]>;
  66. def HasStdExtZfhmin : Predicate<"Subtarget->hasStdExtZfhmin()">,
  67. AssemblerPredicate<(all_of FeatureStdExtZfhmin),
  68. "'Zfhmin' (Half-Precision Floating-Point Minimal)">;
  69. def FeatureStdExtZfh
  70. : SubtargetFeature<"zfh", "HasStdExtZfh", "true",
  71. "'Zfh' (Half-Precision Floating-Point)",
  72. [FeatureStdExtF]>;
  73. def HasStdExtZfh : Predicate<"Subtarget->hasStdExtZfh()">,
  74. AssemblerPredicate<(all_of FeatureStdExtZfh),
  75. "'Zfh' (Half-Precision Floating-Point)">;
  76. def NoStdExtZfh : Predicate<"!Subtarget->hasStdExtZfh()">;
  77. def HasStdExtZfhOrZfhmin
  78. : Predicate<"Subtarget->hasStdExtZfh() || Subtarget->hasStdExtZfhmin()">,
  79. AssemblerPredicate<(any_of FeatureStdExtZfh, FeatureStdExtZfhmin),
  80. "'Zfh' (Half-Precision Floating-Point) or "
  81. "'Zfhmin' (Half-Precision Floating-Point Minimal)">;
  82. def FeatureStdExtZfinx
  83. : SubtargetFeature<"zfinx", "HasStdExtZfinx", "true",
  84. "'Zfinx' (Float in Integer)">;
  85. def HasStdExtZfinx : Predicate<"Subtarget->hasStdExtZfinx()">,
  86. AssemblerPredicate<(all_of FeatureStdExtZfinx),
  87. "'Zfinx' (Float in Integer)">;
  88. def FeatureStdExtZdinx
  89. : SubtargetFeature<"zdinx", "HasStdExtZdinx", "true",
  90. "'Zdinx' (Double in Integer)",
  91. [FeatureStdExtZfinx]>;
  92. def HasStdExtZdinx : Predicate<"Subtarget->hasStdExtZdinx()">,
  93. AssemblerPredicate<(all_of FeatureStdExtZdinx),
  94. "'Zdinx' (Double in Integer)">;
  95. def FeatureStdExtZhinxmin
  96. : SubtargetFeature<"zhinxmin", "HasStdExtZhinxmin", "true",
  97. "'Zhinxmin' (Half Float in Integer Minimal)",
  98. [FeatureStdExtZfinx]>;
  99. def HasStdExtZhinxmin : Predicate<"Subtarget->hasStdExtZhinxmin()">,
  100. AssemblerPredicate<(all_of FeatureStdExtZhinxmin),
  101. "'Zhinxmin' (Half Float in Integer Minimal)">;
  102. def FeatureStdExtZhinx
  103. : SubtargetFeature<"zhinx", "HasStdExtZhinx", "true",
  104. "'Zhinx' (Half Float in Integer)",
  105. [FeatureStdExtZfinx]>;
  106. def HasStdExtZhinx : Predicate<"Subtarget->hasStdExtZhinx()">,
  107. AssemblerPredicate<(all_of FeatureStdExtZhinx),
  108. "'Zhinx' (Half Float in Integer)">;
  109. def HasStdExtZhinxOrZhinxmin
  110. : Predicate<"Subtarget->hasStdExtZhinx() || Subtarget->hasStdExtZhinxmin()">,
  111. AssemblerPredicate<(any_of FeatureStdExtZhinx, FeatureStdExtZhinxmin),
  112. "'Zhinx' (Half Float in Integer) or "
  113. "'Zhinxmin' (Half Float in Integer Minimal)">;
  114. def FeatureStdExtC
  115. : SubtargetFeature<"c", "HasStdExtC", "true",
  116. "'C' (Compressed Instructions)">;
  117. def HasStdExtC : Predicate<"Subtarget->hasStdExtC()">,
  118. AssemblerPredicate<(all_of FeatureStdExtC),
  119. "'C' (Compressed Instructions)">;
  120. def FeatureStdExtZba
  121. : SubtargetFeature<"zba", "HasStdExtZba", "true",
  122. "'Zba' (Address Generation Instructions)">;
  123. def HasStdExtZba : Predicate<"Subtarget->hasStdExtZba()">,
  124. AssemblerPredicate<(all_of FeatureStdExtZba),
  125. "'Zba' (Address Generation Instructions)">;
  126. def NotHasStdExtZba : Predicate<"!Subtarget->hasStdExtZba()">;
  127. def FeatureStdExtZbb
  128. : SubtargetFeature<"zbb", "HasStdExtZbb", "true",
  129. "'Zbb' (Basic Bit-Manipulation)">;
  130. def HasStdExtZbb : Predicate<"Subtarget->hasStdExtZbb()">,
  131. AssemblerPredicate<(all_of FeatureStdExtZbb),
  132. "'Zbb' (Basic Bit-Manipulation)">;
  133. def FeatureStdExtZbc
  134. : SubtargetFeature<"zbc", "HasStdExtZbc", "true",
  135. "'Zbc' (Carry-Less Multiplication)">;
  136. def HasStdExtZbc : Predicate<"Subtarget->hasStdExtZbc()">,
  137. AssemblerPredicate<(all_of FeatureStdExtZbc),
  138. "'Zbc' (Carry-Less Multiplication)">;
  139. def FeatureStdExtZbs
  140. : SubtargetFeature<"zbs", "HasStdExtZbs", "true",
  141. "'Zbs' (Single-Bit Instructions)">;
  142. def HasStdExtZbs : Predicate<"Subtarget->hasStdExtZbs()">,
  143. AssemblerPredicate<(all_of FeatureStdExtZbs),
  144. "'Zbs' (Single-Bit Instructions)">;
  145. def FeatureStdExtZbkb
  146. : SubtargetFeature<"zbkb", "HasStdExtZbkb", "true",
  147. "'Zbkb' (Bitmanip instructions for Cryptography)">;
  148. def HasStdExtZbkb : Predicate<"Subtarget->hasStdExtZbkb()">,
  149. AssemblerPredicate<(all_of FeatureStdExtZbkb),
  150. "'Zbkb' (Bitmanip instructions for Cryptography)">;
  151. def FeatureStdExtZbkx
  152. : SubtargetFeature<"zbkx", "HasStdExtZbkx", "true",
  153. "'Zbkx' (Crossbar permutation instructions)">;
  154. def HasStdExtZbkx : Predicate<"Subtarget->hasStdExtZbkx()">,
  155. AssemblerPredicate<(all_of FeatureStdExtZbkx),
  156. "'Zbkx' (Crossbar permutation instructions)">;
  157. def HasStdExtZbbOrZbkb
  158. : Predicate<"Subtarget->hasStdExtZbb() || Subtarget->hasStdExtZbkb()">,
  159. AssemblerPredicate<(any_of FeatureStdExtZbb, FeatureStdExtZbkb),
  160. "'Zbb' (Basic Bit-Manipulation) or "
  161. "'Zbkb' (Bitmanip instructions for Cryptography)">;
  162. // The Carry-less multiply subextension for cryptography is a subset of basic
  163. // carry-less multiply subextension. The former should be enabled if the latter
  164. // is enabled.
  165. def FeatureStdExtZbkc
  166. : SubtargetFeature<"zbkc", "HasStdExtZbkc", "true",
  167. "'Zbkc' (Carry-less multiply instructions for "
  168. "Cryptography)">;
  169. def HasStdExtZbkc
  170. : Predicate<"Subtarget->hasStdExtZbkc()">,
  171. AssemblerPredicate<(all_of FeatureStdExtZbkc),
  172. "'Zbkc' (Carry-less multiply instructions for Cryptography)">;
  173. def HasStdExtZbcOrZbkc
  174. : Predicate<"Subtarget->hasStdExtZbc() || Subtarget->hasStdExtZbkc()">,
  175. AssemblerPredicate<(any_of FeatureStdExtZbc, FeatureStdExtZbkc),
  176. "'Zbc' (Carry-Less Multiplication) or "
  177. "'Zbkc' (Carry-less multiply instructions "
  178. "for Cryptography)">;
  179. def FeatureStdExtZknd
  180. : SubtargetFeature<"zknd", "HasStdExtZknd", "true",
  181. "'Zknd' (NIST Suite: AES Decryption)">;
  182. def HasStdExtZknd : Predicate<"Subtarget->hasStdExtZknd()">,
  183. AssemblerPredicate<(all_of FeatureStdExtZknd),
  184. "'Zknd' (NIST Suite: AES Decryption)">;
  185. def FeatureStdExtZkne
  186. : SubtargetFeature<"zkne", "HasStdExtZkne", "true",
  187. "'Zkne' (NIST Suite: AES Encryption)">;
  188. def HasStdExtZkne : Predicate<"Subtarget->hasStdExtZkne()">,
  189. AssemblerPredicate<(all_of FeatureStdExtZkne),
  190. "'Zkne' (NIST Suite: AES Encryption)">;
  191. // Some instructions belong to both Zknd and Zkne subextensions.
  192. // They should be enabled if either has been specified.
  193. def HasStdExtZkndOrZkne
  194. : Predicate<"Subtarget->hasStdExtZknd() || Subtarget->hasStdExtZkne()">,
  195. AssemblerPredicate<(any_of FeatureStdExtZknd, FeatureStdExtZkne),
  196. "'Zknd' (NIST Suite: AES Decryption) or "
  197. "'Zkne' (NIST Suite: AES Encryption)">;
  198. def FeatureStdExtZknh
  199. : SubtargetFeature<"zknh", "HasStdExtZknh", "true",
  200. "'Zknh' (NIST Suite: Hash Function Instructions)">;
  201. def HasStdExtZknh : Predicate<"Subtarget->hasStdExtZknh()">,
  202. AssemblerPredicate<(all_of FeatureStdExtZknh),
  203. "'Zknh' (NIST Suite: Hash Function Instructions)">;
  204. def FeatureStdExtZksed
  205. : SubtargetFeature<"zksed", "HasStdExtZksed", "true",
  206. "'Zksed' (ShangMi Suite: SM4 Block Cipher Instructions)">;
  207. def HasStdExtZksed : Predicate<"Subtarget->hasStdExtZksed()">,
  208. AssemblerPredicate<(all_of FeatureStdExtZksed),
  209. "'Zksed' (ShangMi Suite: SM4 Block Cipher Instructions)">;
  210. def FeatureStdExtZksh
  211. : SubtargetFeature<"zksh", "HasStdExtZksh", "true",
  212. "'Zksh' (ShangMi Suite: SM3 Hash Function Instructions)">;
  213. def HasStdExtZksh : Predicate<"Subtarget->hasStdExtZksh()">,
  214. AssemblerPredicate<(all_of FeatureStdExtZksh),
  215. "'Zksh' (ShangMi Suite: SM3 Hash Function "
  216. "Instructions)">;
  217. def FeatureStdExtZkr
  218. : SubtargetFeature<"zkr", "HasStdExtZkr", "true",
  219. "'Zkr' (Entropy Source Extension)">;
  220. def HasStdExtZkr : Predicate<"Subtarget->hasStdExtZkr()">,
  221. AssemblerPredicate<(all_of FeatureStdExtZkr),
  222. "'Zkr' (Entropy Source Extension)">;
  223. def FeatureStdExtZkn
  224. : SubtargetFeature<"zkn", "HasStdExtZkn", "true",
  225. "'Zkn' (NIST Algorithm Suite)",
  226. [FeatureStdExtZbkb,
  227. FeatureStdExtZbkc,
  228. FeatureStdExtZbkx,
  229. FeatureStdExtZkne,
  230. FeatureStdExtZknd,
  231. FeatureStdExtZknh]>;
  232. def FeatureStdExtZks
  233. : SubtargetFeature<"zks", "HasStdExtZks", "true",
  234. "'Zks' (ShangMi Algorithm Suite)",
  235. [FeatureStdExtZbkb,
  236. FeatureStdExtZbkc,
  237. FeatureStdExtZbkx,
  238. FeatureStdExtZksed,
  239. FeatureStdExtZksh]>;
  240. def FeatureStdExtZkt
  241. : SubtargetFeature<"zkt", "HasStdExtZkt", "true",
  242. "'Zkt' (Data Independent Execution Latency)">;
  243. def FeatureStdExtZk
  244. : SubtargetFeature<"zk", "HasStdExtZk", "true",
  245. "'Zk' (Standard scalar cryptography extension)",
  246. [FeatureStdExtZkn,
  247. FeatureStdExtZkr,
  248. FeatureStdExtZkt]>;
  249. def FeatureExtZca
  250. : SubtargetFeature<"experimental-zca", "HasStdExtZca", "true",
  251. "'Zca' (part of the C extension, excluding compressed "
  252. "floating point loads/stores)">;
  253. def HasStdExtCOrZca
  254. : Predicate<"Subtarget->hasStdExtC() || Subtarget->hasStdExtZca()">,
  255. AssemblerPredicate<(any_of FeatureStdExtC, FeatureExtZca),
  256. "'C' (Compressed Instructions) or "
  257. "'Zca' (part of the C extension, excluding "
  258. "compressed floating point loads/stores)">;
  259. def FeatureExtZcd
  260. : SubtargetFeature<"experimental-zcd", "HasStdExtZcd", "true",
  261. "'Zcd' (Compressed Double-Precision Floating-Point Instructions)">;
  262. def HasStdExtCOrZcd
  263. : Predicate<"Subtarget->hasStdExtC() || Subtarget->hasStdExtZcd()">,
  264. AssemblerPredicate<(any_of FeatureStdExtC, FeatureExtZcd),
  265. "'C' (Compressed Instructions) or "
  266. "'Zcd' (Compressed Double-Precision Floating-Point Instructions)">;
  267. def FeatureExtZcf
  268. : SubtargetFeature<"experimental-zcf", "HasStdExtZcf", "true",
  269. "'Zcf' (Compressed Single-Precision Floating-Point Instructions)">;
  270. def HasStdExtCOrZcf
  271. : Predicate<"Subtarget->hasStdExtC() || Subtarget->hasStdExtZcf()">,
  272. AssemblerPredicate<(any_of FeatureStdExtC, FeatureExtZcf),
  273. "'C' (Compressed Instructions) or "
  274. "'Zcf' (Compressed Single-Precision Floating-Point Instructions)">;
  275. def FeatureNoRVCHints
  276. : SubtargetFeature<"no-rvc-hints", "EnableRVCHintInstrs", "false",
  277. "Disable RVC Hint Instructions.">;
  278. def HasRVCHints : Predicate<"Subtarget->enableRVCHintInstrs()">,
  279. AssemblerPredicate<(all_of(not FeatureNoRVCHints)),
  280. "RVC Hint Instructions">;
  281. def FeatureStdExtZvl32b : SubtargetFeature<"zvl32b", "ZvlLen", "32",
  282. "'Zvl' (Minimum Vector Length) 32">;
  283. foreach i = { 6-16 } in {
  284. defvar I = !shl(1, i);
  285. def FeatureStdExtZvl#I#b :
  286. SubtargetFeature<"zvl"#I#"b", "ZvlLen", !cast<string>(I),
  287. "'Zvl' (Minimum Vector Length) "#I,
  288. [!cast<SubtargetFeature>("FeatureStdExtZvl"#!srl(I, 1)#"b")]>;
  289. }
  290. def FeatureStdExtZve32x
  291. : SubtargetFeature<"zve32x", "HasStdExtZve32x", "true",
  292. "'Zve32x' (Vector Extensions for Embedded Processors "
  293. "with maximal 32 EEW)",
  294. [FeatureStdExtZvl32b]>;
  295. def FeatureStdExtZve32f
  296. : SubtargetFeature<"zve32f", "HasStdExtZve32f", "true",
  297. "'Zve32f' (Vector Extensions for Embedded Processors "
  298. "with maximal 32 EEW and F extension)",
  299. [FeatureStdExtZve32x]>;
  300. def FeatureStdExtZve64x
  301. : SubtargetFeature<"zve64x", "HasStdExtZve64x", "true",
  302. "'Zve64x' (Vector Extensions for Embedded Processors "
  303. "with maximal 64 EEW)",
  304. [FeatureStdExtZve32x, FeatureStdExtZvl64b]>;
  305. def FeatureStdExtZve64f
  306. : SubtargetFeature<"zve64f", "HasStdExtZve64f", "true",
  307. "'Zve64f' (Vector Extensions for Embedded Processors "
  308. "with maximal 64 EEW and F extension)",
  309. [FeatureStdExtZve32f, FeatureStdExtZve64x]>;
  310. def FeatureStdExtZve64d
  311. : SubtargetFeature<"zve64d", "HasStdExtZve64d", "true",
  312. "'Zve64d' (Vector Extensions for Embedded Processors "
  313. "with maximal 64 EEW, F and D extension)",
  314. [FeatureStdExtZve64f]>;
  315. def FeatureStdExtV
  316. : SubtargetFeature<"v", "HasStdExtV", "true",
  317. "'V' (Vector Extension for Application Processors)",
  318. [FeatureStdExtZvl128b, FeatureStdExtZve64d,
  319. FeatureStdExtF, FeatureStdExtD]>;
  320. def HasVInstructions : Predicate<"Subtarget->hasVInstructions()">,
  321. AssemblerPredicate<
  322. (any_of FeatureStdExtZve32x),
  323. "'V' (Vector Extension for Application Processors), 'Zve32x' or "
  324. "'Zve64x' (Vector Extensions for Embedded Processors)">;
  325. def HasVInstructionsI64 : Predicate<"Subtarget->hasVInstructionsI64()">,
  326. AssemblerPredicate<
  327. (any_of FeatureStdExtZve64x),
  328. "'V' (Vector Extension for Application Processors) or 'Zve64x' "
  329. "(Vector Extensions for Embedded Processors)">;
  330. def HasVInstructionsAnyF : Predicate<"Subtarget->hasVInstructionsAnyF()">,
  331. AssemblerPredicate<
  332. (any_of FeatureStdExtZve32f),
  333. "'V' (Vector Extension for Application Processors), 'Zve32f', "
  334. "'Zve64f' or 'Zve64d' (Vector Extensions for Embedded Processors)">;
  335. def FeatureStdExtZvfh
  336. : SubtargetFeature<"experimental-zvfh", "HasStdExtZvfh", "true",
  337. "'Zvfh' (Vector Half-Precision Floating-Point)",
  338. [FeatureStdExtZve32f]>;
  339. def FeatureStdExtZicbom
  340. : SubtargetFeature<"zicbom", "HasStdExtZicbom", "true",
  341. "'Zicbom' (Cache-Block Management Instructions)">;
  342. def HasStdExtZicbom : Predicate<"Subtarget->hasStdExtZicbom()">,
  343. AssemblerPredicate<(all_of FeatureStdExtZicbom),
  344. "'Zicbom' (Cache-Block Management Instructions)">;
  345. def FeatureStdExtZicboz
  346. : SubtargetFeature<"zicboz", "HasStdExtZicboz", "true",
  347. "'Zicboz' (Cache-Block Zero Instructions)">;
  348. def HasStdExtZicboz : Predicate<"Subtarget->hasStdExtZicboz()">,
  349. AssemblerPredicate<(all_of FeatureStdExtZicboz),
  350. "'Zicboz' (Cache-Block Zero Instructions)">;
  351. def FeatureStdExtZicbop
  352. : SubtargetFeature<"zicbop", "HasStdExtZicbop", "true",
  353. "'Zicbop' (Cache-Block Prefetch Instructions)">;
  354. def HasStdExtZicbop : Predicate<"Subtarget->hasStdExtZicbop()">,
  355. AssemblerPredicate<(all_of FeatureStdExtZicbop),
  356. "'Zicbop' (Cache-Block Prefetch Instructions)">;
  357. def FeatureStdExtSvnapot
  358. : SubtargetFeature<"svnapot", "HasStdExtSvnapot", "true",
  359. "'Svnapot' (NAPOT Translation Contiguity)">;
  360. def FeatureStdExtSvpbmt
  361. : SubtargetFeature<"svpbmt", "HasStdExtSvpbmt", "true",
  362. "'Svpbmt' (Page-Based Memory Types)">;
  363. def FeatureStdExtSvinval
  364. : SubtargetFeature<"svinval", "HasStdExtSvinval", "true",
  365. "'Svinval' (Fine-Grained Address-Translation Cache Invalidation)">;
  366. def HasStdExtSvinval : Predicate<"Subtarget->hasStdExtSvinval()">,
  367. AssemblerPredicate<(all_of FeatureStdExtSvinval),
  368. "'Svinval' (Fine-Grained Address-Translation Cache Invalidation)">;
  369. def FeatureStdExtZtso
  370. : SubtargetFeature<"experimental-ztso", "HasStdExtZtso", "true",
  371. "'Ztso' (Memory Model - Total Store Order)">;
  372. def HasStdExtZtso : Predicate<"Subtarget->hasStdExtZTso()">,
  373. AssemblerPredicate<(all_of FeatureStdExtZtso),
  374. "'Ztso' (Memory Model - Total Store Order)">;
  375. def FeatureStdExtZawrs
  376. : SubtargetFeature<"experimental-zawrs", "HasStdExtZawrs", "true",
  377. "'Zawrs' (Wait on Reservation Set)">;
  378. def HasStdExtZawrs : Predicate<"Subtarget->hasStdExtZawrs()">,
  379. AssemblerPredicate<(all_of FeatureStdExtZawrs),
  380. "'Zawrs' (Wait on Reservation Set)">;
  381. //===----------------------------------------------------------------------===//
  382. // Vendor extensions
  383. //===----------------------------------------------------------------------===//
  384. def FeatureVendorXVentanaCondOps
  385. : SubtargetFeature<"xventanacondops", "HasVendorXVentanaCondOps", "true",
  386. "'XVentanaCondOps' (Ventana Conditional Ops)">;
  387. def HasVendorXVentanaCondOps : Predicate<"Subtarget->hasVendorXVentanaCondOps()">,
  388. AssemblerPredicate<(all_of FeatureVendorXVentanaCondOps),
  389. "'XVentanaCondOps' (Ventana Conditional Ops)">;
  390. def FeatureVendorXTHeadVdot
  391. : SubtargetFeature<"xtheadvdot", "HasVendorXTHeadVdot", "true",
  392. "'xtheadvdot' (T-Head Vector Extensions for Dot)",
  393. [FeatureStdExtV]>;
  394. def HasVendorXTHeadVdot : Predicate<"Subtarget->hasVendorXTHeadVdot()">,
  395. AssemblerPredicate<(all_of FeatureVendorXTHeadVdot),
  396. "'xtheadvdot' (T-Head Vector Extensions for Dot)">;
  397. //===----------------------------------------------------------------------===//
  398. // LLVM specific features and extensions
  399. //===----------------------------------------------------------------------===//
  400. // Feature32Bit exists to mark CPUs that support RV32 to distinquish them from
  401. // tuning CPU names.
  402. def Feature32Bit
  403. : SubtargetFeature<"32bit", "HasRV32", "true", "Implements RV32">;
  404. def Feature64Bit
  405. : SubtargetFeature<"64bit", "HasRV64", "true", "Implements RV64">;
  406. def IsRV64 : Predicate<"Subtarget->is64Bit()">,
  407. AssemblerPredicate<(all_of Feature64Bit),
  408. "RV64I Base Instruction Set">;
  409. def IsRV32 : Predicate<"!Subtarget->is64Bit()">,
  410. AssemblerPredicate<(all_of (not Feature64Bit)),
  411. "RV32I Base Instruction Set">;
  412. defvar RV32 = DefaultMode;
  413. def RV64 : HwMode<"+64bit">;
  414. def FeatureRV32E
  415. : SubtargetFeature<"e", "IsRV32E", "true",
  416. "Implements RV32E (provides 16 rather than 32 GPRs)">;
  417. def IsRV32E : Predicate<"Subtarget->isRV32E()">,
  418. AssemblerPredicate<(all_of FeatureRV32E)>;
  419. def FeatureRelax
  420. : SubtargetFeature<"relax", "EnableLinkerRelax", "true",
  421. "Enable Linker relaxation.">;
  422. foreach i = {1-31} in
  423. def FeatureReserveX#i :
  424. SubtargetFeature<"reserve-x"#i, "UserReservedRegister[RISCV::X"#i#"]",
  425. "true", "Reserve X"#i>;
  426. def FeatureSaveRestore : SubtargetFeature<"save-restore", "EnableSaveRestore",
  427. "true", "Enable save/restore.">;
  428. def FeatureUnalignedScalarMem
  429. : SubtargetFeature<"unaligned-scalar-mem", "EnableUnalignedScalarMem",
  430. "true", "Has reasonably performant unaligned scalar "
  431. "loads and stores">;
  432. def TuneNoOptimizedZeroStrideLoad
  433. : SubtargetFeature<"no-optimized-zero-stride-load", "HasOptimizedZeroStrideLoad",
  434. "false", "Hasn't optimized (perform fewer memory operations)"
  435. "zero-stride vector load">;
  436. def TuneLUIADDIFusion
  437. : SubtargetFeature<"lui-addi-fusion", "HasLUIADDIFusion",
  438. "true", "Enable LUI+ADDI macrofusion">;
  439. def TuneNoDefaultUnroll
  440. : SubtargetFeature<"no-default-unroll", "EnableDefaultUnroll", "false",
  441. "Disable default unroll preference.">;
  442. // SiFive 7 is able to fuse integer ALU operations with a preceding branch
  443. // instruction.
  444. def TuneShortForwardBranchOpt
  445. : SubtargetFeature<"short-forward-branch-opt", "HasShortForwardBranchOpt",
  446. "true", "Enable short forward branch optimization">;
  447. def HasShortForwardBranchOpt : Predicate<"Subtarget->hasShortForwardBranchOpt()">;
  448. def NoShortForwardBranchOpt : Predicate<"!Subtarget->hasShortForwardBranchOpt()">;
  449. def TuneSiFive7 : SubtargetFeature<"sifive7", "RISCVProcFamily", "SiFive7",
  450. "SiFive 7-Series processors",
  451. [TuneNoDefaultUnroll,
  452. TuneShortForwardBranchOpt]>;
  453. // Assume that lock-free native-width atomics are available, even if the target
  454. // and operating system combination would not usually provide them. The user
  455. // is responsible for providing any necessary __sync implementations. Code
  456. // built with this feature is not ABI-compatible with code built without this
  457. // feature, if atomic variables are exposed across the ABI boundary.
  458. def FeatureForcedAtomics : SubtargetFeature<
  459. "forced-atomics", "HasForcedAtomics", "true",
  460. "Assume that lock-free native-width atomics are available">;
  461. def HasAtomicLdSt
  462. : Predicate<"Subtarget->hasStdExtA() || Subtarget->hasForcedAtomics()">;
  463. def FeatureTaggedGlobals : SubtargetFeature<"tagged-globals",
  464. "AllowTaggedGlobals",
  465. "true", "Use an instruction sequence for taking the address of a global "
  466. "that allows a memory tag in the upper address bits">;