GenericOpcodes.td 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  1. //===-- GenericOpcodes.td - Opcodes used with GlobalISel ---*- 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. // This file defines the generic opcodes used with GlobalISel.
  10. // After instruction selection, these opcodes should not appear.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //------------------------------------------------------------------------------
  14. // Unary ops.
  15. //------------------------------------------------------------------------------
  16. class GenericInstruction : StandardPseudoInstruction {
  17. let isPreISelOpcode = true;
  18. }
  19. // Provide a variant of an instruction with the same operands, but
  20. // different instruction flags. This is intended to provide a
  21. // convenient way to define strict floating point variants of ordinary
  22. // floating point instructions.
  23. class ConstrainedIntruction<GenericInstruction baseInst> :
  24. GenericInstruction {
  25. let OutOperandList = baseInst.OutOperandList;
  26. let InOperandList = baseInst.InOperandList;
  27. let isCommutable = baseInst.isCommutable;
  28. // TODO: Do we need a better way to mark reads from FP mode than
  29. // hasSideEffects?
  30. let hasSideEffects = true;
  31. let mayRaiseFPException = true;
  32. }
  33. // Extend the underlying scalar type of an operation, leaving the high bits
  34. // unspecified.
  35. def G_ANYEXT : GenericInstruction {
  36. let OutOperandList = (outs type0:$dst);
  37. let InOperandList = (ins type1:$src);
  38. let hasSideEffects = false;
  39. }
  40. // Sign extend the underlying scalar type of an operation, copying the sign bit
  41. // into the newly-created space.
  42. def G_SEXT : GenericInstruction {
  43. let OutOperandList = (outs type0:$dst);
  44. let InOperandList = (ins type1:$src);
  45. let hasSideEffects = false;
  46. }
  47. // Sign extend the a value from an arbitrary bit position, copying the sign bit
  48. // into all bits above it. This is equivalent to a shl + ashr pair with an
  49. // appropriate shift amount. $sz is an immediate (MachineOperand::isImm()
  50. // returns true) to allow targets to have some bitwidths legal and others
  51. // lowered. This opcode is particularly useful if the target has sign-extension
  52. // instructions that are cheaper than the constituent shifts as the optimizer is
  53. // able to make decisions on whether it's better to hang on to the G_SEXT_INREG
  54. // or to lower it and optimize the individual shifts.
  55. def G_SEXT_INREG : GenericInstruction {
  56. let OutOperandList = (outs type0:$dst);
  57. let InOperandList = (ins type0:$src, untyped_imm_0:$sz);
  58. let hasSideEffects = false;
  59. }
  60. // Zero extend the underlying scalar type of an operation, putting zero bits
  61. // into the newly-created space.
  62. def G_ZEXT : GenericInstruction {
  63. let OutOperandList = (outs type0:$dst);
  64. let InOperandList = (ins type1:$src);
  65. let hasSideEffects = false;
  66. }
  67. // Truncate the underlying scalar type of an operation. This is equivalent to
  68. // G_EXTRACT for scalar types, but acts elementwise on vectors.
  69. def G_TRUNC : GenericInstruction {
  70. let OutOperandList = (outs type0:$dst);
  71. let InOperandList = (ins type1:$src);
  72. let hasSideEffects = false;
  73. }
  74. def G_IMPLICIT_DEF : GenericInstruction {
  75. let OutOperandList = (outs type0:$dst);
  76. let InOperandList = (ins);
  77. let hasSideEffects = false;
  78. }
  79. def G_PHI : GenericInstruction {
  80. let OutOperandList = (outs type0:$dst);
  81. let InOperandList = (ins variable_ops);
  82. let hasSideEffects = false;
  83. }
  84. def G_FRAME_INDEX : GenericInstruction {
  85. let OutOperandList = (outs type0:$dst);
  86. let InOperandList = (ins unknown:$src2);
  87. let hasSideEffects = false;
  88. }
  89. def G_GLOBAL_VALUE : GenericInstruction {
  90. let OutOperandList = (outs type0:$dst);
  91. let InOperandList = (ins unknown:$src);
  92. let hasSideEffects = false;
  93. }
  94. def G_INTTOPTR : GenericInstruction {
  95. let OutOperandList = (outs type0:$dst);
  96. let InOperandList = (ins type1:$src);
  97. let hasSideEffects = false;
  98. }
  99. def G_PTRTOINT : GenericInstruction {
  100. let OutOperandList = (outs type0:$dst);
  101. let InOperandList = (ins type1:$src);
  102. let hasSideEffects = false;
  103. }
  104. def G_BITCAST : GenericInstruction {
  105. let OutOperandList = (outs type0:$dst);
  106. let InOperandList = (ins type1:$src);
  107. let hasSideEffects = false;
  108. }
  109. // Only supports scalar result types
  110. def G_CONSTANT : GenericInstruction {
  111. let OutOperandList = (outs type0:$dst);
  112. let InOperandList = (ins unknown:$imm);
  113. let hasSideEffects = false;
  114. }
  115. // Only supports scalar result types
  116. def G_FCONSTANT : GenericInstruction {
  117. let OutOperandList = (outs type0:$dst);
  118. let InOperandList = (ins unknown:$imm);
  119. let hasSideEffects = false;
  120. }
  121. def G_VASTART : GenericInstruction {
  122. let OutOperandList = (outs);
  123. let InOperandList = (ins type0:$list);
  124. let hasSideEffects = false;
  125. let mayStore = true;
  126. }
  127. def G_VAARG : GenericInstruction {
  128. let OutOperandList = (outs type0:$val);
  129. let InOperandList = (ins type1:$list, unknown:$align);
  130. let hasSideEffects = false;
  131. let mayLoad = true;
  132. let mayStore = true;
  133. }
  134. def G_CTLZ : GenericInstruction {
  135. let OutOperandList = (outs type0:$dst);
  136. let InOperandList = (ins type1:$src);
  137. let hasSideEffects = false;
  138. }
  139. def G_CTLZ_ZERO_UNDEF : GenericInstruction {
  140. let OutOperandList = (outs type0:$dst);
  141. let InOperandList = (ins type1:$src);
  142. let hasSideEffects = false;
  143. }
  144. def G_CTTZ : GenericInstruction {
  145. let OutOperandList = (outs type0:$dst);
  146. let InOperandList = (ins type1:$src);
  147. let hasSideEffects = false;
  148. }
  149. def G_CTTZ_ZERO_UNDEF : GenericInstruction {
  150. let OutOperandList = (outs type0:$dst);
  151. let InOperandList = (ins type1:$src);
  152. let hasSideEffects = false;
  153. }
  154. def G_CTPOP : GenericInstruction {
  155. let OutOperandList = (outs type0:$dst);
  156. let InOperandList = (ins type1:$src);
  157. let hasSideEffects = false;
  158. }
  159. def G_BSWAP : GenericInstruction {
  160. let OutOperandList = (outs type0:$dst);
  161. let InOperandList = (ins type0:$src);
  162. let hasSideEffects = false;
  163. }
  164. def G_BITREVERSE : GenericInstruction {
  165. let OutOperandList = (outs type0:$dst);
  166. let InOperandList = (ins type0:$src);
  167. let hasSideEffects = false;
  168. }
  169. def G_ADDRSPACE_CAST : GenericInstruction {
  170. let OutOperandList = (outs type0:$dst);
  171. let InOperandList = (ins type1:$src);
  172. let hasSideEffects = false;
  173. }
  174. def G_BLOCK_ADDR : GenericInstruction {
  175. let OutOperandList = (outs type0:$dst);
  176. let InOperandList = (ins unknown:$ba);
  177. let hasSideEffects = false;
  178. }
  179. def G_JUMP_TABLE : GenericInstruction {
  180. let OutOperandList = (outs type0:$dst);
  181. let InOperandList = (ins unknown:$jti);
  182. let hasSideEffects = false;
  183. }
  184. def G_DYN_STACKALLOC : GenericInstruction {
  185. let OutOperandList = (outs ptype0:$dst);
  186. let InOperandList = (ins type1:$size, i32imm:$align);
  187. let hasSideEffects = true;
  188. }
  189. def G_FREEZE : GenericInstruction {
  190. let OutOperandList = (outs type0:$dst);
  191. let InOperandList = (ins type0:$src);
  192. let hasSideEffects = false;
  193. }
  194. //------------------------------------------------------------------------------
  195. // Binary ops.
  196. //------------------------------------------------------------------------------
  197. // Generic addition.
  198. def G_ADD : GenericInstruction {
  199. let OutOperandList = (outs type0:$dst);
  200. let InOperandList = (ins type0:$src1, type0:$src2);
  201. let hasSideEffects = false;
  202. let isCommutable = true;
  203. }
  204. // Generic subtraction.
  205. def G_SUB : GenericInstruction {
  206. let OutOperandList = (outs type0:$dst);
  207. let InOperandList = (ins type0:$src1, type0:$src2);
  208. let hasSideEffects = false;
  209. let isCommutable = false;
  210. }
  211. // Generic multiplication.
  212. def G_MUL : GenericInstruction {
  213. let OutOperandList = (outs type0:$dst);
  214. let InOperandList = (ins type0:$src1, type0:$src2);
  215. let hasSideEffects = false;
  216. let isCommutable = true;
  217. }
  218. // Generic signed division.
  219. def G_SDIV : GenericInstruction {
  220. let OutOperandList = (outs type0:$dst);
  221. let InOperandList = (ins type0:$src1, type0:$src2);
  222. let hasSideEffects = false;
  223. let isCommutable = false;
  224. }
  225. // Generic unsigned division.
  226. def G_UDIV : GenericInstruction {
  227. let OutOperandList = (outs type0:$dst);
  228. let InOperandList = (ins type0:$src1, type0:$src2);
  229. let hasSideEffects = false;
  230. let isCommutable = false;
  231. }
  232. // Generic signed remainder.
  233. def G_SREM : GenericInstruction {
  234. let OutOperandList = (outs type0:$dst);
  235. let InOperandList = (ins type0:$src1, type0:$src2);
  236. let hasSideEffects = false;
  237. let isCommutable = false;
  238. }
  239. // Generic unsigned remainder.
  240. def G_UREM : GenericInstruction {
  241. let OutOperandList = (outs type0:$dst);
  242. let InOperandList = (ins type0:$src1, type0:$src2);
  243. let hasSideEffects = false;
  244. let isCommutable = false;
  245. }
  246. // Generic bitwise and.
  247. def G_AND : GenericInstruction {
  248. let OutOperandList = (outs type0:$dst);
  249. let InOperandList = (ins type0:$src1, type0:$src2);
  250. let hasSideEffects = false;
  251. let isCommutable = true;
  252. }
  253. // Generic bitwise or.
  254. def G_OR : GenericInstruction {
  255. let OutOperandList = (outs type0:$dst);
  256. let InOperandList = (ins type0:$src1, type0:$src2);
  257. let hasSideEffects = false;
  258. let isCommutable = true;
  259. }
  260. // Generic bitwise xor.
  261. def G_XOR : GenericInstruction {
  262. let OutOperandList = (outs type0:$dst);
  263. let InOperandList = (ins type0:$src1, type0:$src2);
  264. let hasSideEffects = false;
  265. let isCommutable = true;
  266. }
  267. // Generic left-shift.
  268. def G_SHL : GenericInstruction {
  269. let OutOperandList = (outs type0:$dst);
  270. let InOperandList = (ins type0:$src1, type1:$src2);
  271. let hasSideEffects = false;
  272. }
  273. // Generic logical right-shift.
  274. def G_LSHR : GenericInstruction {
  275. let OutOperandList = (outs type0:$dst);
  276. let InOperandList = (ins type0:$src1, type1:$src2);
  277. let hasSideEffects = false;
  278. }
  279. // Generic arithmetic right-shift.
  280. def G_ASHR : GenericInstruction {
  281. let OutOperandList = (outs type0:$dst);
  282. let InOperandList = (ins type0:$src1, type1:$src2);
  283. let hasSideEffects = false;
  284. }
  285. /// Funnel 'double' shifts take 3 operands, 2 inputs and the shift amount.
  286. /// fshl(X,Y,Z): (X << (Z % bitwidth)) | (Y >> (bitwidth - (Z % bitwidth)))
  287. def G_FSHL : GenericInstruction {
  288. let OutOperandList = (outs type0:$dst);
  289. let InOperandList = (ins type0:$src1, type0:$src2, type1:$src3);
  290. let hasSideEffects = false;
  291. }
  292. /// Funnel 'double' shifts take 3 operands, 2 inputs and the shift amount.
  293. /// fshr(X,Y,Z): (X << (bitwidth - (Z % bitwidth))) | (Y >> (Z % bitwidth))
  294. def G_FSHR : GenericInstruction {
  295. let OutOperandList = (outs type0:$dst);
  296. let InOperandList = (ins type0:$src1, type0:$src2, type1:$src3);
  297. let hasSideEffects = false;
  298. }
  299. // Generic integer comparison.
  300. def G_ICMP : GenericInstruction {
  301. let OutOperandList = (outs type0:$dst);
  302. let InOperandList = (ins unknown:$tst, type1:$src1, type1:$src2);
  303. let hasSideEffects = false;
  304. }
  305. // Generic floating-point comparison.
  306. def G_FCMP : GenericInstruction {
  307. let OutOperandList = (outs type0:$dst);
  308. let InOperandList = (ins unknown:$tst, type1:$src1, type1:$src2);
  309. let hasSideEffects = false;
  310. }
  311. // Generic select
  312. def G_SELECT : GenericInstruction {
  313. let OutOperandList = (outs type0:$dst);
  314. let InOperandList = (ins type1:$tst, type0:$src1, type0:$src2);
  315. let hasSideEffects = false;
  316. }
  317. // Generic pointer offset.
  318. def G_PTR_ADD : GenericInstruction {
  319. let OutOperandList = (outs type0:$dst);
  320. let InOperandList = (ins type0:$src1, type1:$src2);
  321. let hasSideEffects = false;
  322. }
  323. // Generic pointer mask. type1 should be an integer with the same
  324. // bitwidth as the pointer type.
  325. def G_PTRMASK : GenericInstruction {
  326. let OutOperandList = (outs ptype0:$dst);
  327. let InOperandList = (ins ptype0:$src, type1:$bits);
  328. let hasSideEffects = false;
  329. }
  330. // Generic signed integer minimum.
  331. def G_SMIN : GenericInstruction {
  332. let OutOperandList = (outs type0:$dst);
  333. let InOperandList = (ins type0:$src1, type0:$src2);
  334. let hasSideEffects = false;
  335. let isCommutable = true;
  336. }
  337. // Generic signed integer maximum.
  338. def G_SMAX : GenericInstruction {
  339. let OutOperandList = (outs type0:$dst);
  340. let InOperandList = (ins type0:$src1, type0:$src2);
  341. let hasSideEffects = false;
  342. let isCommutable = true;
  343. }
  344. // Generic unsigned integer minimum.
  345. def G_UMIN : GenericInstruction {
  346. let OutOperandList = (outs type0:$dst);
  347. let InOperandList = (ins type0:$src1, type0:$src2);
  348. let hasSideEffects = false;
  349. let isCommutable = true;
  350. }
  351. // Generic unsigned integer maximum.
  352. def G_UMAX : GenericInstruction {
  353. let OutOperandList = (outs type0:$dst);
  354. let InOperandList = (ins type0:$src1, type0:$src2);
  355. let hasSideEffects = false;
  356. let isCommutable = true;
  357. }
  358. // Generic integer absolute value.
  359. def G_ABS : GenericInstruction {
  360. let OutOperandList = (outs type0:$dst);
  361. let InOperandList = (ins type0:$src);
  362. let hasSideEffects = false;
  363. }
  364. //------------------------------------------------------------------------------
  365. // Overflow ops
  366. //------------------------------------------------------------------------------
  367. // Generic unsigned addition producing a carry flag.
  368. def G_UADDO : GenericInstruction {
  369. let OutOperandList = (outs type0:$dst, type1:$carry_out);
  370. let InOperandList = (ins type0:$src1, type0:$src2);
  371. let hasSideEffects = false;
  372. let isCommutable = true;
  373. }
  374. // Generic unsigned addition consuming and producing a carry flag.
  375. def G_UADDE : GenericInstruction {
  376. let OutOperandList = (outs type0:$dst, type1:$carry_out);
  377. let InOperandList = (ins type0:$src1, type0:$src2, type1:$carry_in);
  378. let hasSideEffects = false;
  379. }
  380. // Generic signed addition producing a carry flag.
  381. def G_SADDO : GenericInstruction {
  382. let OutOperandList = (outs type0:$dst, type1:$carry_out);
  383. let InOperandList = (ins type0:$src1, type0:$src2);
  384. let hasSideEffects = false;
  385. let isCommutable = true;
  386. }
  387. // Generic signed addition consuming and producing a carry flag.
  388. def G_SADDE : GenericInstruction {
  389. let OutOperandList = (outs type0:$dst, type1:$carry_out);
  390. let InOperandList = (ins type0:$src1, type0:$src2, type1:$carry_in);
  391. let hasSideEffects = false;
  392. }
  393. // Generic unsigned subtraction producing a carry flag.
  394. def G_USUBO : GenericInstruction {
  395. let OutOperandList = (outs type0:$dst, type1:$carry_out);
  396. let InOperandList = (ins type0:$src1, type0:$src2);
  397. let hasSideEffects = false;
  398. }
  399. // Generic unsigned subtraction consuming and producing a carry flag.
  400. def G_USUBE : GenericInstruction {
  401. let OutOperandList = (outs type0:$dst, type1:$carry_out);
  402. let InOperandList = (ins type0:$src1, type0:$src2, type1:$carry_in);
  403. let hasSideEffects = false;
  404. }
  405. // Generic signed subtraction producing a carry flag.
  406. def G_SSUBO : GenericInstruction {
  407. let OutOperandList = (outs type0:$dst, type1:$carry_out);
  408. let InOperandList = (ins type0:$src1, type0:$src2);
  409. let hasSideEffects = false;
  410. }
  411. // Generic signed subtraction consuming and producing a carry flag.
  412. def G_SSUBE : GenericInstruction {
  413. let OutOperandList = (outs type0:$dst, type1:$carry_out);
  414. let InOperandList = (ins type0:$src1, type0:$src2, type1:$carry_in);
  415. let hasSideEffects = false;
  416. }
  417. // Generic unsigned multiplication producing a carry flag.
  418. def G_UMULO : GenericInstruction {
  419. let OutOperandList = (outs type0:$dst, type1:$carry_out);
  420. let InOperandList = (ins type0:$src1, type0:$src2);
  421. let hasSideEffects = false;
  422. let isCommutable = true;
  423. }
  424. // Generic signed multiplication producing a carry flag.
  425. def G_SMULO : GenericInstruction {
  426. let OutOperandList = (outs type0:$dst, type1:$carry_out);
  427. let InOperandList = (ins type0:$src1, type0:$src2);
  428. let hasSideEffects = false;
  429. let isCommutable = true;
  430. }
  431. // Multiply two numbers at twice the incoming bit width (unsigned) and return
  432. // the high half of the result.
  433. def G_UMULH : GenericInstruction {
  434. let OutOperandList = (outs type0:$dst);
  435. let InOperandList = (ins type0:$src1, type0:$src2);
  436. let hasSideEffects = false;
  437. let isCommutable = true;
  438. }
  439. // Multiply two numbers at twice the incoming bit width (signed) and return
  440. // the high half of the result.
  441. def G_SMULH : GenericInstruction {
  442. let OutOperandList = (outs type0:$dst);
  443. let InOperandList = (ins type0:$src1, type0:$src2);
  444. let hasSideEffects = false;
  445. let isCommutable = true;
  446. }
  447. //------------------------------------------------------------------------------
  448. // Saturating ops
  449. //------------------------------------------------------------------------------
  450. // Generic saturating unsigned addition.
  451. def G_UADDSAT : GenericInstruction {
  452. let OutOperandList = (outs type0:$dst);
  453. let InOperandList = (ins type0:$src1, type0:$src2);
  454. let hasSideEffects = false;
  455. let isCommutable = true;
  456. }
  457. // Generic saturating signed addition.
  458. def G_SADDSAT : GenericInstruction {
  459. let OutOperandList = (outs type0:$dst);
  460. let InOperandList = (ins type0:$src1, type0:$src2);
  461. let hasSideEffects = false;
  462. let isCommutable = true;
  463. }
  464. // Generic saturating unsigned subtraction.
  465. def G_USUBSAT : GenericInstruction {
  466. let OutOperandList = (outs type0:$dst);
  467. let InOperandList = (ins type0:$src1, type0:$src2);
  468. let hasSideEffects = false;
  469. let isCommutable = false;
  470. }
  471. // Generic saturating signed subtraction.
  472. def G_SSUBSAT : GenericInstruction {
  473. let OutOperandList = (outs type0:$dst);
  474. let InOperandList = (ins type0:$src1, type0:$src2);
  475. let hasSideEffects = false;
  476. let isCommutable = false;
  477. }
  478. // Generic saturating unsigned left shift.
  479. def G_USHLSAT : GenericInstruction {
  480. let OutOperandList = (outs type0:$dst);
  481. let InOperandList = (ins type0:$src1, type1:$src2);
  482. let hasSideEffects = false;
  483. let isCommutable = false;
  484. }
  485. // Generic saturating signed left shift.
  486. def G_SSHLSAT : GenericInstruction {
  487. let OutOperandList = (outs type0:$dst);
  488. let InOperandList = (ins type0:$src1, type1:$src2);
  489. let hasSideEffects = false;
  490. let isCommutable = false;
  491. }
  492. /// RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point
  493. /// multiplication on 2 integers with the same width and scale. SCALE
  494. /// represents the scale of both operands as fixed point numbers. This
  495. /// SCALE parameter must be a constant integer. A scale of zero is
  496. /// effectively performing multiplication on 2 integers.
  497. def G_SMULFIX : GenericInstruction {
  498. let OutOperandList = (outs type0:$dst);
  499. let InOperandList = (ins type0:$src0, type0:$src1, untyped_imm_0:$scale);
  500. let hasSideEffects = false;
  501. let isCommutable = true;
  502. }
  503. def G_UMULFIX : GenericInstruction {
  504. let OutOperandList = (outs type0:$dst);
  505. let InOperandList = (ins type0:$src0, type0:$src1, untyped_imm_0:$scale);
  506. let hasSideEffects = false;
  507. let isCommutable = true;
  508. }
  509. /// Same as the corresponding unsaturated fixed point instructions, but the
  510. /// result is clamped between the min and max values representable by the
  511. /// bits of the first 2 operands.
  512. def G_SMULFIXSAT : GenericInstruction {
  513. let OutOperandList = (outs type0:$dst);
  514. let InOperandList = (ins type0:$src0, type0:$src1, untyped_imm_0:$scale);
  515. let hasSideEffects = false;
  516. let isCommutable = true;
  517. }
  518. def G_UMULFIXSAT : GenericInstruction {
  519. let OutOperandList = (outs type0:$dst);
  520. let InOperandList = (ins type0:$src0, type0:$src1, untyped_imm_0:$scale);
  521. let hasSideEffects = false;
  522. let isCommutable = true;
  523. }
  524. /// RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on
  525. /// 2 integers with the same width and scale. SCALE represents the scale
  526. /// of both operands as fixed point numbers. This SCALE parameter must be a
  527. /// constant integer.
  528. def G_SDIVFIX : GenericInstruction {
  529. let OutOperandList = (outs type0:$dst);
  530. let InOperandList = (ins type0:$src0, type0:$src1, untyped_imm_0:$scale);
  531. let hasSideEffects = false;
  532. let isCommutable = false;
  533. }
  534. def G_UDIVFIX : GenericInstruction {
  535. let OutOperandList = (outs type0:$dst);
  536. let InOperandList = (ins type0:$src0, type0:$src1, untyped_imm_0:$scale);
  537. let hasSideEffects = false;
  538. let isCommutable = false;
  539. }
  540. /// Same as the corresponding unsaturated fixed point instructions,
  541. /// but the result is clamped between the min and max values
  542. /// representable by the bits of the first 2 operands.
  543. def G_SDIVFIXSAT : GenericInstruction {
  544. let OutOperandList = (outs type0:$dst);
  545. let InOperandList = (ins type0:$src0, type0:$src1, untyped_imm_0:$scale);
  546. let hasSideEffects = false;
  547. let isCommutable = false;
  548. }
  549. def G_UDIVFIXSAT : GenericInstruction {
  550. let OutOperandList = (outs type0:$dst);
  551. let InOperandList = (ins type0:$src0, type0:$src1, untyped_imm_0:$scale);
  552. let hasSideEffects = false;
  553. let isCommutable = false;
  554. }
  555. //------------------------------------------------------------------------------
  556. // Floating Point Unary Ops.
  557. //------------------------------------------------------------------------------
  558. def G_FNEG : GenericInstruction {
  559. let OutOperandList = (outs type0:$dst);
  560. let InOperandList = (ins type0:$src);
  561. let hasSideEffects = false;
  562. }
  563. def G_FPEXT : GenericInstruction {
  564. let OutOperandList = (outs type0:$dst);
  565. let InOperandList = (ins type1:$src);
  566. let hasSideEffects = false;
  567. }
  568. def G_FPTRUNC : GenericInstruction {
  569. let OutOperandList = (outs type0:$dst);
  570. let InOperandList = (ins type1:$src);
  571. let hasSideEffects = false;
  572. }
  573. def G_FPTOSI : GenericInstruction {
  574. let OutOperandList = (outs type0:$dst);
  575. let InOperandList = (ins type1:$src);
  576. let hasSideEffects = false;
  577. }
  578. def G_FPTOUI : GenericInstruction {
  579. let OutOperandList = (outs type0:$dst);
  580. let InOperandList = (ins type1:$src);
  581. let hasSideEffects = false;
  582. }
  583. def G_SITOFP : GenericInstruction {
  584. let OutOperandList = (outs type0:$dst);
  585. let InOperandList = (ins type1:$src);
  586. let hasSideEffects = false;
  587. }
  588. def G_UITOFP : GenericInstruction {
  589. let OutOperandList = (outs type0:$dst);
  590. let InOperandList = (ins type1:$src);
  591. let hasSideEffects = false;
  592. }
  593. def G_FABS : GenericInstruction {
  594. let OutOperandList = (outs type0:$dst);
  595. let InOperandList = (ins type0:$src);
  596. let hasSideEffects = false;
  597. }
  598. def G_FCOPYSIGN : GenericInstruction {
  599. let OutOperandList = (outs type0:$dst);
  600. let InOperandList = (ins type0:$src0, type1:$src1);
  601. let hasSideEffects = false;
  602. }
  603. def G_FCANONICALIZE : GenericInstruction {
  604. let OutOperandList = (outs type0:$dst);
  605. let InOperandList = (ins type0:$src);
  606. let hasSideEffects = false;
  607. }
  608. // FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two
  609. // values.
  610. //
  611. // In the case where a single input is a NaN (either signaling or quiet),
  612. // the non-NaN input is returned.
  613. //
  614. // The return value of (FMINNUM 0.0, -0.0) could be either 0.0 or -0.0.
  615. def G_FMINNUM : GenericInstruction {
  616. let OutOperandList = (outs type0:$dst);
  617. let InOperandList = (ins type0:$src1, type0:$src2);
  618. let hasSideEffects = false;
  619. let isCommutable = true;
  620. }
  621. def G_FMAXNUM : GenericInstruction {
  622. let OutOperandList = (outs type0:$dst);
  623. let InOperandList = (ins type0:$src1, type0:$src2);
  624. let hasSideEffects = false;
  625. let isCommutable = true;
  626. }
  627. // FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimum or maximum on
  628. // two values, following the IEEE-754 2008 definition. This differs from
  629. // FMINNUM/FMAXNUM in the handling of signaling NaNs. If one input is a
  630. // signaling NaN, returns a quiet NaN.
  631. def G_FMINNUM_IEEE : GenericInstruction {
  632. let OutOperandList = (outs type0:$dst);
  633. let InOperandList = (ins type0:$src1, type0:$src2);
  634. let hasSideEffects = false;
  635. let isCommutable = true;
  636. }
  637. def G_FMAXNUM_IEEE : GenericInstruction {
  638. let OutOperandList = (outs type0:$dst);
  639. let InOperandList = (ins type0:$src1, type0:$src2);
  640. let hasSideEffects = false;
  641. let isCommutable = true;
  642. }
  643. // FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0
  644. // as less than 0.0. While FMINNUM_IEEE/FMAXNUM_IEEE follow IEEE 754-2008
  645. // semantics, FMINIMUM/FMAXIMUM follow IEEE 754-2018 draft semantics.
  646. def G_FMINIMUM : GenericInstruction {
  647. let OutOperandList = (outs type0:$dst);
  648. let InOperandList = (ins type0:$src1, type0:$src2);
  649. let hasSideEffects = false;
  650. let isCommutable = true;
  651. }
  652. def G_FMAXIMUM : GenericInstruction {
  653. let OutOperandList = (outs type0:$dst);
  654. let InOperandList = (ins type0:$src1, type0:$src2);
  655. let hasSideEffects = false;
  656. let isCommutable = true;
  657. }
  658. //------------------------------------------------------------------------------
  659. // Floating Point Binary ops.
  660. //------------------------------------------------------------------------------
  661. // Generic FP addition.
  662. def G_FADD : GenericInstruction {
  663. let OutOperandList = (outs type0:$dst);
  664. let InOperandList = (ins type0:$src1, type0:$src2);
  665. let hasSideEffects = false;
  666. let isCommutable = true;
  667. }
  668. // Generic FP subtraction.
  669. def G_FSUB : GenericInstruction {
  670. let OutOperandList = (outs type0:$dst);
  671. let InOperandList = (ins type0:$src1, type0:$src2);
  672. let hasSideEffects = false;
  673. let isCommutable = false;
  674. }
  675. // Generic FP multiplication.
  676. def G_FMUL : GenericInstruction {
  677. let OutOperandList = (outs type0:$dst);
  678. let InOperandList = (ins type0:$src1, type0:$src2);
  679. let hasSideEffects = false;
  680. let isCommutable = true;
  681. }
  682. // Generic fused multiply-add instruction.
  683. // Behaves like llvm fma intrinsic ie src1 * src2 + src3
  684. def G_FMA : GenericInstruction {
  685. let OutOperandList = (outs type0:$dst);
  686. let InOperandList = (ins type0:$src1, type0:$src2, type0:$src3);
  687. let hasSideEffects = false;
  688. let isCommutable = false;
  689. }
  690. /// Generic FP multiply and add. Perform a * b + c, while getting the
  691. /// same result as the separately rounded operations, unlike G_FMA.
  692. def G_FMAD : GenericInstruction {
  693. let OutOperandList = (outs type0:$dst);
  694. let InOperandList = (ins type0:$src1, type0:$src2, type0:$src3);
  695. let hasSideEffects = false;
  696. let isCommutable = false;
  697. }
  698. // Generic FP division.
  699. def G_FDIV : GenericInstruction {
  700. let OutOperandList = (outs type0:$dst);
  701. let InOperandList = (ins type0:$src1, type0:$src2);
  702. let hasSideEffects = false;
  703. }
  704. // Generic FP remainder.
  705. def G_FREM : GenericInstruction {
  706. let OutOperandList = (outs type0:$dst);
  707. let InOperandList = (ins type0:$src1, type0:$src2);
  708. let hasSideEffects = false;
  709. }
  710. // Floating point exponentiation.
  711. def G_FPOW : GenericInstruction {
  712. let OutOperandList = (outs type0:$dst);
  713. let InOperandList = (ins type0:$src1, type0:$src2);
  714. let hasSideEffects = false;
  715. }
  716. // Floating point exponentiation, with an integer power.
  717. def G_FPOWI : GenericInstruction {
  718. let OutOperandList = (outs type0:$dst);
  719. let InOperandList = (ins type0:$src0, type1:$src1);
  720. let hasSideEffects = false;
  721. }
  722. // Floating point base-e exponential of a value.
  723. def G_FEXP : GenericInstruction {
  724. let OutOperandList = (outs type0:$dst);
  725. let InOperandList = (ins type0:$src1);
  726. let hasSideEffects = false;
  727. }
  728. // Floating point base-2 exponential of a value.
  729. def G_FEXP2 : GenericInstruction {
  730. let OutOperandList = (outs type0:$dst);
  731. let InOperandList = (ins type0:$src1);
  732. let hasSideEffects = false;
  733. }
  734. // Floating point base-e logarithm of a value.
  735. def G_FLOG : GenericInstruction {
  736. let OutOperandList = (outs type0:$dst);
  737. let InOperandList = (ins type0:$src1);
  738. let hasSideEffects = false;
  739. }
  740. // Floating point base-2 logarithm of a value.
  741. def G_FLOG2 : GenericInstruction {
  742. let OutOperandList = (outs type0:$dst);
  743. let InOperandList = (ins type0:$src1);
  744. let hasSideEffects = false;
  745. }
  746. // Floating point base-10 logarithm of a value.
  747. def G_FLOG10 : GenericInstruction {
  748. let OutOperandList = (outs type0:$dst);
  749. let InOperandList = (ins type0:$src1);
  750. let hasSideEffects = false;
  751. }
  752. // Floating point ceiling of a value.
  753. def G_FCEIL : GenericInstruction {
  754. let OutOperandList = (outs type0:$dst);
  755. let InOperandList = (ins type0:$src1);
  756. let hasSideEffects = false;
  757. }
  758. // Floating point cosine of a value.
  759. def G_FCOS : GenericInstruction {
  760. let OutOperandList = (outs type0:$dst);
  761. let InOperandList = (ins type0:$src1);
  762. let hasSideEffects = false;
  763. }
  764. // Floating point sine of a value.
  765. def G_FSIN : GenericInstruction {
  766. let OutOperandList = (outs type0:$dst);
  767. let InOperandList = (ins type0:$src1);
  768. let hasSideEffects = false;
  769. }
  770. // Floating point square root of a value.
  771. // This returns NaN for negative nonzero values.
  772. // NOTE: Unlike libm sqrt(), this never sets errno. In all other respects it's
  773. // libm-conformant.
  774. def G_FSQRT : GenericInstruction {
  775. let OutOperandList = (outs type0:$dst);
  776. let InOperandList = (ins type0:$src1);
  777. let hasSideEffects = false;
  778. }
  779. // Floating point floor of a value.
  780. def G_FFLOOR : GenericInstruction {
  781. let OutOperandList = (outs type0:$dst);
  782. let InOperandList = (ins type0:$src1);
  783. let hasSideEffects = false;
  784. }
  785. // Floating point round to next integer.
  786. def G_FRINT : GenericInstruction {
  787. let OutOperandList = (outs type0:$dst);
  788. let InOperandList = (ins type0:$src1);
  789. let hasSideEffects = false;
  790. }
  791. // Floating point round to the nearest integer.
  792. def G_FNEARBYINT : GenericInstruction {
  793. let OutOperandList = (outs type0:$dst);
  794. let InOperandList = (ins type0:$src1);
  795. let hasSideEffects = false;
  796. }
  797. //------------------------------------------------------------------------------
  798. // Opcodes for LLVM Intrinsics
  799. //------------------------------------------------------------------------------
  800. def G_INTRINSIC_TRUNC : GenericInstruction {
  801. let OutOperandList = (outs type0:$dst);
  802. let InOperandList = (ins type0:$src1);
  803. let hasSideEffects = false;
  804. }
  805. def G_INTRINSIC_ROUND : GenericInstruction {
  806. let OutOperandList = (outs type0:$dst);
  807. let InOperandList = (ins type0:$src1);
  808. let hasSideEffects = false;
  809. }
  810. def G_INTRINSIC_LRINT : GenericInstruction {
  811. let OutOperandList = (outs type0:$dst);
  812. let InOperandList = (ins type1:$src);
  813. let hasSideEffects = false;
  814. }
  815. def G_INTRINSIC_ROUNDEVEN : GenericInstruction {
  816. let OutOperandList = (outs type0:$dst);
  817. let InOperandList = (ins type0:$src1);
  818. let hasSideEffects = false;
  819. }
  820. def G_READCYCLECOUNTER : GenericInstruction {
  821. let OutOperandList = (outs type0:$dst);
  822. let InOperandList = (ins);
  823. let hasSideEffects = true;
  824. }
  825. //------------------------------------------------------------------------------
  826. // Memory ops
  827. //------------------------------------------------------------------------------
  828. // Generic load. Expects a MachineMemOperand in addition to explicit
  829. // operands. If the result size is larger than the memory size, the
  830. // high bits are undefined. If the result is a vector type and larger
  831. // than the memory size, the high elements are undefined (i.e. this is
  832. // not a per-element, vector anyextload)
  833. def G_LOAD : GenericInstruction {
  834. let OutOperandList = (outs type0:$dst);
  835. let InOperandList = (ins ptype1:$addr);
  836. let hasSideEffects = false;
  837. let mayLoad = true;
  838. }
  839. // Generic sign-extended load. Expects a MachineMemOperand in addition to explicit operands.
  840. def G_SEXTLOAD : GenericInstruction {
  841. let OutOperandList = (outs type0:$dst);
  842. let InOperandList = (ins ptype1:$addr);
  843. let hasSideEffects = false;
  844. let mayLoad = true;
  845. }
  846. // Generic zero-extended load. Expects a MachineMemOperand in addition to explicit operands.
  847. def G_ZEXTLOAD : GenericInstruction {
  848. let OutOperandList = (outs type0:$dst);
  849. let InOperandList = (ins ptype1:$addr);
  850. let hasSideEffects = false;
  851. let mayLoad = true;
  852. }
  853. // Generic indexed load. Combines a GEP with a load. $newaddr is set to $base + $offset.
  854. // If $am is 0 (post-indexed), then the value is loaded from $base; if $am is 1 (pre-indexed)
  855. // then the value is loaded from $newaddr.
  856. def G_INDEXED_LOAD : GenericInstruction {
  857. let OutOperandList = (outs type0:$dst, ptype1:$newaddr);
  858. let InOperandList = (ins ptype1:$base, type2:$offset, unknown:$am);
  859. let hasSideEffects = false;
  860. let mayLoad = true;
  861. }
  862. // Same as G_INDEXED_LOAD except that the load performed is sign-extending, as with G_SEXTLOAD.
  863. def G_INDEXED_SEXTLOAD : GenericInstruction {
  864. let OutOperandList = (outs type0:$dst, ptype1:$newaddr);
  865. let InOperandList = (ins ptype1:$base, type2:$offset, unknown:$am);
  866. let hasSideEffects = false;
  867. let mayLoad = true;
  868. }
  869. // Same as G_INDEXED_LOAD except that the load performed is zero-extending, as with G_ZEXTLOAD.
  870. def G_INDEXED_ZEXTLOAD : GenericInstruction {
  871. let OutOperandList = (outs type0:$dst, ptype1:$newaddr);
  872. let InOperandList = (ins ptype1:$base, type2:$offset, unknown:$am);
  873. let hasSideEffects = false;
  874. let mayLoad = true;
  875. }
  876. // Generic store. Expects a MachineMemOperand in addition to explicit operands.
  877. def G_STORE : GenericInstruction {
  878. let OutOperandList = (outs);
  879. let InOperandList = (ins type0:$src, ptype1:$addr);
  880. let hasSideEffects = false;
  881. let mayStore = true;
  882. }
  883. // Combines a store with a GEP. See description of G_INDEXED_LOAD for indexing behaviour.
  884. def G_INDEXED_STORE : GenericInstruction {
  885. let OutOperandList = (outs ptype0:$newaddr);
  886. let InOperandList = (ins type1:$src, ptype0:$base, ptype2:$offset,
  887. unknown:$am);
  888. let hasSideEffects = false;
  889. let mayStore = true;
  890. }
  891. // Generic atomic cmpxchg with internal success check. Expects a
  892. // MachineMemOperand in addition to explicit operands.
  893. def G_ATOMIC_CMPXCHG_WITH_SUCCESS : GenericInstruction {
  894. let OutOperandList = (outs type0:$oldval, type1:$success);
  895. let InOperandList = (ins type2:$addr, type0:$cmpval, type0:$newval);
  896. let hasSideEffects = false;
  897. let mayLoad = true;
  898. let mayStore = true;
  899. }
  900. // Generic atomic cmpxchg. Expects a MachineMemOperand in addition to explicit
  901. // operands.
  902. def G_ATOMIC_CMPXCHG : GenericInstruction {
  903. let OutOperandList = (outs type0:$oldval);
  904. let InOperandList = (ins ptype1:$addr, type0:$cmpval, type0:$newval);
  905. let hasSideEffects = false;
  906. let mayLoad = true;
  907. let mayStore = true;
  908. }
  909. // Generic atomicrmw. Expects a MachineMemOperand in addition to explicit
  910. // operands.
  911. class G_ATOMICRMW_OP : GenericInstruction {
  912. let OutOperandList = (outs type0:$oldval);
  913. let InOperandList = (ins ptype1:$addr, type0:$val);
  914. let hasSideEffects = false;
  915. let mayLoad = true;
  916. let mayStore = true;
  917. }
  918. def G_ATOMICRMW_XCHG : G_ATOMICRMW_OP;
  919. def G_ATOMICRMW_ADD : G_ATOMICRMW_OP;
  920. def G_ATOMICRMW_SUB : G_ATOMICRMW_OP;
  921. def G_ATOMICRMW_AND : G_ATOMICRMW_OP;
  922. def G_ATOMICRMW_NAND : G_ATOMICRMW_OP;
  923. def G_ATOMICRMW_OR : G_ATOMICRMW_OP;
  924. def G_ATOMICRMW_XOR : G_ATOMICRMW_OP;
  925. def G_ATOMICRMW_MAX : G_ATOMICRMW_OP;
  926. def G_ATOMICRMW_MIN : G_ATOMICRMW_OP;
  927. def G_ATOMICRMW_UMAX : G_ATOMICRMW_OP;
  928. def G_ATOMICRMW_UMIN : G_ATOMICRMW_OP;
  929. def G_ATOMICRMW_FADD : G_ATOMICRMW_OP;
  930. def G_ATOMICRMW_FSUB : G_ATOMICRMW_OP;
  931. def G_FENCE : GenericInstruction {
  932. let OutOperandList = (outs);
  933. let InOperandList = (ins i32imm:$ordering, i32imm:$scope);
  934. let hasSideEffects = true;
  935. }
  936. //------------------------------------------------------------------------------
  937. // Variadic ops
  938. //------------------------------------------------------------------------------
  939. // Extract a register of the specified size, starting from the block given by
  940. // index. This will almost certainly be mapped to sub-register COPYs after
  941. // register banks have been selected.
  942. def G_EXTRACT : GenericInstruction {
  943. let OutOperandList = (outs type0:$res);
  944. let InOperandList = (ins type1:$src, untyped_imm_0:$offset);
  945. let hasSideEffects = false;
  946. }
  947. // Extract multiple registers specified size, starting from blocks given by
  948. // indexes. This will almost certainly be mapped to sub-register COPYs after
  949. // register banks have been selected.
  950. // The output operands are always ordered from lowest bits to highest:
  951. // %bits_0_7:(s8), %bits_8_15:(s8),
  952. // %bits_16_23:(s8), %bits_24_31:(s8) = G_UNMERGE_VALUES %0:(s32)
  953. def G_UNMERGE_VALUES : GenericInstruction {
  954. let OutOperandList = (outs type0:$dst0, variable_ops);
  955. let InOperandList = (ins type1:$src);
  956. let hasSideEffects = false;
  957. }
  958. // Insert a smaller register into a larger one at the specified bit-index.
  959. def G_INSERT : GenericInstruction {
  960. let OutOperandList = (outs type0:$dst);
  961. let InOperandList = (ins type0:$src, type1:$op, untyped_imm_0:$offset);
  962. let hasSideEffects = false;
  963. }
  964. // Concatenate multiple registers of the same size into a wider register.
  965. // The input operands are always ordered from lowest bits to highest:
  966. // %0:(s32) = G_MERGE_VALUES %bits_0_7:(s8), %bits_8_15:(s8),
  967. // %bits_16_23:(s8), %bits_24_31:(s8)
  968. def G_MERGE_VALUES : GenericInstruction {
  969. let OutOperandList = (outs type0:$dst);
  970. let InOperandList = (ins type1:$src0, variable_ops);
  971. let hasSideEffects = false;
  972. }
  973. /// Create a vector from multiple scalar registers. No implicit
  974. /// conversion is performed (i.e. the result element type must be the
  975. /// same as all source operands)
  976. def G_BUILD_VECTOR : GenericInstruction {
  977. let OutOperandList = (outs type0:$dst);
  978. let InOperandList = (ins type1:$src0, variable_ops);
  979. let hasSideEffects = false;
  980. }
  981. /// Like G_BUILD_VECTOR, but truncates the larger operand types to fit the
  982. /// destination vector elt type.
  983. def G_BUILD_VECTOR_TRUNC : GenericInstruction {
  984. let OutOperandList = (outs type0:$dst);
  985. let InOperandList = (ins type1:$src0, variable_ops);
  986. let hasSideEffects = false;
  987. }
  988. /// Create a vector by concatenating vectors together.
  989. def G_CONCAT_VECTORS : GenericInstruction {
  990. let OutOperandList = (outs type0:$dst);
  991. let InOperandList = (ins type1:$src0, variable_ops);
  992. let hasSideEffects = false;
  993. }
  994. // Intrinsic without side effects.
  995. def G_INTRINSIC : GenericInstruction {
  996. let OutOperandList = (outs);
  997. let InOperandList = (ins unknown:$intrin, variable_ops);
  998. let hasSideEffects = false;
  999. // Conservatively assume this is convergent. If there turnes out to
  1000. // be a need, there should be separate convergent intrinsic opcodes.
  1001. let isConvergent = 1;
  1002. }
  1003. // Intrinsic with side effects.
  1004. def G_INTRINSIC_W_SIDE_EFFECTS : GenericInstruction {
  1005. let OutOperandList = (outs);
  1006. let InOperandList = (ins unknown:$intrin, variable_ops);
  1007. let hasSideEffects = true;
  1008. let mayLoad = true;
  1009. let mayStore = true;
  1010. // Conservatively assume this is convergent. If there turnes out to
  1011. // be a need, there should be separate convergent intrinsic opcodes.
  1012. let isConvergent = true;
  1013. }
  1014. //------------------------------------------------------------------------------
  1015. // Branches.
  1016. //------------------------------------------------------------------------------
  1017. // Generic unconditional branch.
  1018. def G_BR : GenericInstruction {
  1019. let OutOperandList = (outs);
  1020. let InOperandList = (ins unknown:$src1);
  1021. let hasSideEffects = false;
  1022. let isBranch = true;
  1023. let isTerminator = true;
  1024. let isBarrier = true;
  1025. }
  1026. // Generic conditional branch.
  1027. def G_BRCOND : GenericInstruction {
  1028. let OutOperandList = (outs);
  1029. let InOperandList = (ins type0:$tst, unknown:$truebb);
  1030. let hasSideEffects = false;
  1031. let isBranch = true;
  1032. let isTerminator = true;
  1033. }
  1034. // Generic indirect branch.
  1035. def G_BRINDIRECT : GenericInstruction {
  1036. let OutOperandList = (outs);
  1037. let InOperandList = (ins type0:$src1);
  1038. let hasSideEffects = false;
  1039. let isBranch = true;
  1040. let isTerminator = true;
  1041. let isBarrier = true;
  1042. let isIndirectBranch = true;
  1043. }
  1044. // Generic branch to jump table entry
  1045. def G_BRJT : GenericInstruction {
  1046. let OutOperandList = (outs);
  1047. let InOperandList = (ins ptype0:$tbl, unknown:$jti, type1:$idx);
  1048. let hasSideEffects = false;
  1049. let isBranch = true;
  1050. let isTerminator = true;
  1051. let isBarrier = true;
  1052. let isIndirectBranch = true;
  1053. }
  1054. def G_READ_REGISTER : GenericInstruction {
  1055. let OutOperandList = (outs type0:$dst);
  1056. let InOperandList = (ins unknown:$register);
  1057. let hasSideEffects = true;
  1058. // Assume convergent. It's probably not worth the effort of somehow
  1059. // modeling convergent and nonconvergent register accesses.
  1060. let isConvergent = true;
  1061. }
  1062. def G_WRITE_REGISTER : GenericInstruction {
  1063. let OutOperandList = (outs);
  1064. let InOperandList = (ins unknown:$register, type0:$value);
  1065. let hasSideEffects = true;
  1066. // Assume convergent. It's probably not worth the effort of somehow
  1067. // modeling convergent and nonconvergent register accesses.
  1068. let isConvergent = true;
  1069. }
  1070. //------------------------------------------------------------------------------
  1071. // Vector ops
  1072. //------------------------------------------------------------------------------
  1073. // Generic insertelement.
  1074. def G_INSERT_VECTOR_ELT : GenericInstruction {
  1075. let OutOperandList = (outs type0:$dst);
  1076. let InOperandList = (ins type0:$src, type1:$elt, type2:$idx);
  1077. let hasSideEffects = false;
  1078. }
  1079. // Generic extractelement.
  1080. def G_EXTRACT_VECTOR_ELT : GenericInstruction {
  1081. let OutOperandList = (outs type0:$dst);
  1082. let InOperandList = (ins type1:$src, type2:$idx);
  1083. let hasSideEffects = false;
  1084. }
  1085. // Generic shufflevector.
  1086. //
  1087. // The mask operand should be an IR Constant which exactly matches the
  1088. // corresponding mask for the IR shufflevector instruction.
  1089. def G_SHUFFLE_VECTOR: GenericInstruction {
  1090. let OutOperandList = (outs type0:$dst);
  1091. let InOperandList = (ins type1:$v1, type1:$v2, unknown:$mask);
  1092. let hasSideEffects = false;
  1093. }
  1094. //------------------------------------------------------------------------------
  1095. // Vector reductions
  1096. //------------------------------------------------------------------------------
  1097. class VectorReduction : GenericInstruction {
  1098. let OutOperandList = (outs type0:$dst);
  1099. let InOperandList = (ins type1:$v);
  1100. let hasSideEffects = false;
  1101. }
  1102. def G_VECREDUCE_SEQ_FADD : GenericInstruction {
  1103. let OutOperandList = (outs type0:$dst);
  1104. let InOperandList = (ins type1:$acc, type2:$v);
  1105. let hasSideEffects = false;
  1106. }
  1107. def G_VECREDUCE_SEQ_FMUL : GenericInstruction {
  1108. let OutOperandList = (outs type0:$dst);
  1109. let InOperandList = (ins type1:$acc, type2:$v);
  1110. let hasSideEffects = false;
  1111. }
  1112. def G_VECREDUCE_FADD : VectorReduction;
  1113. def G_VECREDUCE_FMUL : VectorReduction;
  1114. def G_VECREDUCE_FMAX : VectorReduction;
  1115. def G_VECREDUCE_FMIN : VectorReduction;
  1116. def G_VECREDUCE_ADD : VectorReduction;
  1117. def G_VECREDUCE_MUL : VectorReduction;
  1118. def G_VECREDUCE_AND : VectorReduction;
  1119. def G_VECREDUCE_OR : VectorReduction;
  1120. def G_VECREDUCE_XOR : VectorReduction;
  1121. def G_VECREDUCE_SMAX : VectorReduction;
  1122. def G_VECREDUCE_SMIN : VectorReduction;
  1123. def G_VECREDUCE_UMAX : VectorReduction;
  1124. def G_VECREDUCE_UMIN : VectorReduction;
  1125. //------------------------------------------------------------------------------
  1126. // Constrained floating point ops
  1127. //------------------------------------------------------------------------------
  1128. def G_STRICT_FADD : ConstrainedIntruction<G_FADD>;
  1129. def G_STRICT_FSUB : ConstrainedIntruction<G_FSUB>;
  1130. def G_STRICT_FMUL : ConstrainedIntruction<G_FMUL>;
  1131. def G_STRICT_FDIV : ConstrainedIntruction<G_FDIV>;
  1132. def G_STRICT_FREM : ConstrainedIntruction<G_FREM>;
  1133. def G_STRICT_FMA : ConstrainedIntruction<G_FMA>;
  1134. def G_STRICT_FSQRT : ConstrainedIntruction<G_FSQRT>;
  1135. //------------------------------------------------------------------------------
  1136. // Memory intrinsics
  1137. //------------------------------------------------------------------------------
  1138. def G_MEMCPY : GenericInstruction {
  1139. let OutOperandList = (outs);
  1140. let InOperandList = (ins ptype0:$dst_addr, ptype1:$src_addr, type2:$size, untyped_imm_0:$tailcall);
  1141. let hasSideEffects = false;
  1142. let mayLoad = true;
  1143. let mayStore = true;
  1144. }
  1145. def G_MEMMOVE : GenericInstruction {
  1146. let OutOperandList = (outs);
  1147. let InOperandList = (ins ptype0:$dst_addr, ptype1:$src_addr, type2:$size, untyped_imm_0:$tailcall);
  1148. let hasSideEffects = false;
  1149. let mayLoad = true;
  1150. let mayStore = true;
  1151. }
  1152. def G_MEMSET : GenericInstruction {
  1153. let OutOperandList = (outs);
  1154. let InOperandList = (ins ptype0:$dst_addr, type1:$value, type2:$size, untyped_imm_0:$tailcall);
  1155. let hasSideEffects = false;
  1156. let mayStore = true;
  1157. }