TargetSelectionDAG.td 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648
  1. //===- TargetSelectionDAG.td - Common code for DAG isels ---*- 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 target-independent interfaces used by SelectionDAG
  10. // instruction selection generators.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //===----------------------------------------------------------------------===//
  14. // Selection DAG Type Constraint definitions.
  15. //
  16. // Note that the semantics of these constraints are hard coded into tblgen. To
  17. // modify or add constraints, you have to hack tblgen.
  18. //
  19. class SDTypeConstraint<int opnum> {
  20. int OperandNum = opnum;
  21. }
  22. // SDTCisVT - The specified operand has exactly this VT.
  23. class SDTCisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
  24. ValueType VT = vt;
  25. }
  26. class SDTCisPtrTy<int OpNum> : SDTypeConstraint<OpNum>;
  27. // SDTCisInt - The specified operand has integer type.
  28. class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>;
  29. // SDTCisFP - The specified operand has floating-point type.
  30. class SDTCisFP<int OpNum> : SDTypeConstraint<OpNum>;
  31. // SDTCisVec - The specified operand has a vector type.
  32. class SDTCisVec<int OpNum> : SDTypeConstraint<OpNum>;
  33. // SDTCisSameAs - The two specified operands have identical types.
  34. class SDTCisSameAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
  35. int OtherOperandNum = OtherOp;
  36. }
  37. // SDTCisVTSmallerThanOp - The specified operand is a VT SDNode, and its type is
  38. // smaller than the 'Other' operand.
  39. class SDTCisVTSmallerThanOp<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
  40. int OtherOperandNum = OtherOp;
  41. }
  42. class SDTCisOpSmallerThanOp<int SmallOp, int BigOp> : SDTypeConstraint<SmallOp>{
  43. int BigOperandNum = BigOp;
  44. }
  45. /// SDTCisEltOfVec - This indicates that ThisOp is a scalar type of the same
  46. /// type as the element type of OtherOp, which is a vector type.
  47. class SDTCisEltOfVec<int ThisOp, int OtherOp>
  48. : SDTypeConstraint<ThisOp> {
  49. int OtherOpNum = OtherOp;
  50. }
  51. /// SDTCisSubVecOfVec - This indicates that ThisOp is a vector type
  52. /// with length less that of OtherOp, which is a vector type.
  53. class SDTCisSubVecOfVec<int ThisOp, int OtherOp>
  54. : SDTypeConstraint<ThisOp> {
  55. int OtherOpNum = OtherOp;
  56. }
  57. // SDTCVecEltisVT - The specified operand is vector type with element type
  58. // of VT.
  59. class SDTCVecEltisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
  60. ValueType VT = vt;
  61. }
  62. // SDTCisSameNumEltsAs - The two specified operands have identical number
  63. // of elements.
  64. class SDTCisSameNumEltsAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
  65. int OtherOperandNum = OtherOp;
  66. }
  67. // SDTCisSameSizeAs - The two specified operands have identical size.
  68. class SDTCisSameSizeAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
  69. int OtherOperandNum = OtherOp;
  70. }
  71. //===----------------------------------------------------------------------===//
  72. // Selection DAG Type Profile definitions.
  73. //
  74. // These use the constraints defined above to describe the type requirements of
  75. // the various nodes. These are not hard coded into tblgen, allowing targets to
  76. // add their own if needed.
  77. //
  78. // SDTypeProfile - This profile describes the type requirements of a Selection
  79. // DAG node.
  80. class SDTypeProfile<int numresults, int numoperands,
  81. list<SDTypeConstraint> constraints> {
  82. int NumResults = numresults;
  83. int NumOperands = numoperands;
  84. list<SDTypeConstraint> Constraints = constraints;
  85. }
  86. // Builtin profiles.
  87. def SDTIntLeaf: SDTypeProfile<1, 0, [SDTCisInt<0>]>; // for 'imm'.
  88. def SDTFPLeaf : SDTypeProfile<1, 0, [SDTCisFP<0>]>; // for 'fpimm'.
  89. def SDTPtrLeaf: SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>; // for '&g'.
  90. def SDTOther : SDTypeProfile<1, 0, [SDTCisVT<0, OtherVT>]>; // for 'vt'.
  91. def SDTUNDEF : SDTypeProfile<1, 0, []>; // for 'undef'.
  92. def SDTUnaryOp : SDTypeProfile<1, 1, []>; // for bitconvert.
  93. def SDTIntBinOp : SDTypeProfile<1, 2, [ // add, and, or, xor, udiv, etc.
  94. SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>
  95. ]>;
  96. def SDTIntShiftOp : SDTypeProfile<1, 2, [ // shl, sra, srl
  97. SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisInt<2>
  98. ]>;
  99. def SDTIntShiftDOp: SDTypeProfile<1, 3, [ // fshl, fshr
  100. SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>, SDTCisInt<3>
  101. ]>;
  102. def SDTIntSatNoShOp : SDTypeProfile<1, 2, [ // ssat with no shift
  103. SDTCisSameAs<0, 1>, SDTCisInt<2>
  104. ]>;
  105. def SDTIntBinHiLoOp : SDTypeProfile<2, 2, [ // mulhi, mullo, sdivrem, udivrem
  106. SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,SDTCisInt<0>
  107. ]>;
  108. def SDTIntScaledBinOp : SDTypeProfile<1, 3, [ // smulfix, sdivfix, etc
  109. SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>, SDTCisInt<3>
  110. ]>;
  111. def SDTFPBinOp : SDTypeProfile<1, 2, [ // fadd, fmul, etc.
  112. SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisFP<0>
  113. ]>;
  114. def SDTFPSignOp : SDTypeProfile<1, 2, [ // fcopysign.
  115. SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisFP<2>
  116. ]>;
  117. def SDTFPTernaryOp : SDTypeProfile<1, 3, [ // fmadd, fnmsub, etc.
  118. SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisFP<0>
  119. ]>;
  120. def SDTIntUnaryOp : SDTypeProfile<1, 1, [ // bitreverse
  121. SDTCisSameAs<0, 1>, SDTCisInt<0>
  122. ]>;
  123. def SDTIntBitCountUnaryOp : SDTypeProfile<1, 1, [ // ctlz, cttz
  124. SDTCisInt<0>, SDTCisInt<1>
  125. ]>;
  126. def SDTIntExtendOp : SDTypeProfile<1, 1, [ // sext, zext, anyext
  127. SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisSameNumEltsAs<0, 1>
  128. ]>;
  129. def SDTIntTruncOp : SDTypeProfile<1, 1, [ // trunc
  130. SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<0, 1>, SDTCisSameNumEltsAs<0, 1>
  131. ]>;
  132. def SDTFPUnaryOp : SDTypeProfile<1, 1, [ // fneg, fsqrt, etc
  133. SDTCisSameAs<0, 1>, SDTCisFP<0>
  134. ]>;
  135. def SDTFPRoundOp : SDTypeProfile<1, 1, [ // fround
  136. SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1>, SDTCisSameNumEltsAs<0, 1>
  137. ]>;
  138. def SDTFPExtendOp : SDTypeProfile<1, 1, [ // fextend
  139. SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisSameNumEltsAs<0, 1>
  140. ]>;
  141. def SDTIntToFPOp : SDTypeProfile<1, 1, [ // [su]int_to_fp
  142. SDTCisFP<0>, SDTCisInt<1>, SDTCisSameNumEltsAs<0, 1>
  143. ]>;
  144. def SDTFPToIntOp : SDTypeProfile<1, 1, [ // fp_to_[su]int
  145. SDTCisInt<0>, SDTCisFP<1>, SDTCisSameNumEltsAs<0, 1>
  146. ]>;
  147. def SDTFPToIntSatOp : SDTypeProfile<1, 2, [ // fp_to_[su]int_sat
  148. SDTCisInt<0>, SDTCisFP<1>, SDTCisInt<2>, SDTCisSameNumEltsAs<0, 1>
  149. ]>;
  150. def SDTExtInreg : SDTypeProfile<1, 2, [ // sext_inreg
  151. SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisVT<2, OtherVT>,
  152. SDTCisVTSmallerThanOp<2, 1>
  153. ]>;
  154. def SDTExtInvec : SDTypeProfile<1, 1, [ // sext_invec
  155. SDTCisInt<0>, SDTCisVec<0>, SDTCisInt<1>, SDTCisVec<1>,
  156. SDTCisOpSmallerThanOp<1, 0>
  157. ]>;
  158. def SDTSetCC : SDTypeProfile<1, 3, [ // setcc
  159. SDTCisInt<0>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>
  160. ]>;
  161. def SDTSelect : SDTypeProfile<1, 3, [ // select
  162. SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3>
  163. ]>;
  164. def SDTVSelect : SDTypeProfile<1, 3, [ // vselect
  165. SDTCisVec<0>, SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<2, 3>, SDTCisSameNumEltsAs<0, 1>
  166. ]>;
  167. def SDTSelectCC : SDTypeProfile<1, 5, [ // select_cc
  168. SDTCisSameAs<1, 2>, SDTCisSameAs<3, 4>, SDTCisSameAs<0, 3>,
  169. SDTCisVT<5, OtherVT>
  170. ]>;
  171. def SDTBr : SDTypeProfile<0, 1, [ // br
  172. SDTCisVT<0, OtherVT>
  173. ]>;
  174. def SDTBrCC : SDTypeProfile<0, 4, [ // brcc
  175. SDTCisVT<0, OtherVT>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>
  176. ]>;
  177. def SDTBrcond : SDTypeProfile<0, 2, [ // brcond
  178. SDTCisInt<0>, SDTCisVT<1, OtherVT>
  179. ]>;
  180. def SDTBrind : SDTypeProfile<0, 1, [ // brind
  181. SDTCisPtrTy<0>
  182. ]>;
  183. def SDTCatchret : SDTypeProfile<0, 2, [ // catchret
  184. SDTCisVT<0, OtherVT>, SDTCisVT<1, OtherVT>
  185. ]>;
  186. def SDTNone : SDTypeProfile<0, 0, []>; // ret, trap
  187. def SDTUBSANTrap : SDTypeProfile<0, 1, []>; // ubsantrap
  188. def SDTLoad : SDTypeProfile<1, 1, [ // load
  189. SDTCisPtrTy<1>
  190. ]>;
  191. def SDTStore : SDTypeProfile<0, 2, [ // store
  192. SDTCisPtrTy<1>
  193. ]>;
  194. def SDTIStore : SDTypeProfile<1, 3, [ // indexed store
  195. SDTCisSameAs<0, 2>, SDTCisPtrTy<0>, SDTCisPtrTy<3>
  196. ]>;
  197. def SDTMaskedStore: SDTypeProfile<0, 4, [ // masked store
  198. SDTCisVec<0>, SDTCisPtrTy<1>, SDTCisPtrTy<2>, SDTCisVec<3>, SDTCisSameNumEltsAs<0, 3>
  199. ]>;
  200. def SDTMaskedLoad: SDTypeProfile<1, 4, [ // masked load
  201. SDTCisVec<0>, SDTCisPtrTy<1>, SDTCisPtrTy<2>, SDTCisVec<3>, SDTCisSameAs<0, 4>,
  202. SDTCisSameNumEltsAs<0, 3>
  203. ]>;
  204. def SDTVecShuffle : SDTypeProfile<1, 2, [
  205. SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>
  206. ]>;
  207. def SDTVecExtract : SDTypeProfile<1, 2, [ // vector extract
  208. SDTCisEltOfVec<0, 1>, SDTCisPtrTy<2>
  209. ]>;
  210. def SDTVecInsert : SDTypeProfile<1, 3, [ // vector insert
  211. SDTCisEltOfVec<2, 1>, SDTCisSameAs<0, 1>, SDTCisPtrTy<3>
  212. ]>;
  213. def SDTVecReduce : SDTypeProfile<1, 1, [ // vector reduction
  214. SDTCisInt<0>, SDTCisVec<1>
  215. ]>;
  216. def SDTFPVecReduce : SDTypeProfile<1, 1, [ // FP vector reduction
  217. SDTCisFP<0>, SDTCisVec<1>
  218. ]>;
  219. def SDTSubVecExtract : SDTypeProfile<1, 2, [// subvector extract
  220. SDTCisSubVecOfVec<0,1>, SDTCisInt<2>
  221. ]>;
  222. def SDTSubVecInsert : SDTypeProfile<1, 3, [ // subvector insert
  223. SDTCisSubVecOfVec<2, 1>, SDTCisSameAs<0,1>, SDTCisInt<3>
  224. ]>;
  225. def SDTPrefetch : SDTypeProfile<0, 4, [ // prefetch
  226. SDTCisPtrTy<0>, SDTCisSameAs<1, 2>, SDTCisSameAs<1, 3>, SDTCisInt<1>
  227. ]>;
  228. def SDTMemBarrier : SDTypeProfile<0, 5, [ // memory barrier
  229. SDTCisSameAs<0,1>, SDTCisSameAs<0,2>, SDTCisSameAs<0,3>, SDTCisSameAs<0,4>,
  230. SDTCisInt<0>
  231. ]>;
  232. def SDTAtomicFence : SDTypeProfile<0, 2, [
  233. SDTCisSameAs<0,1>, SDTCisPtrTy<0>
  234. ]>;
  235. def SDTAtomic3 : SDTypeProfile<1, 3, [
  236. SDTCisSameAs<0,2>, SDTCisSameAs<0,3>, SDTCisInt<0>, SDTCisPtrTy<1>
  237. ]>;
  238. def SDTAtomic2 : SDTypeProfile<1, 2, [
  239. SDTCisSameAs<0,2>, SDTCisInt<0>, SDTCisPtrTy<1>
  240. ]>;
  241. def SDTFPAtomic2 : SDTypeProfile<1, 2, [
  242. SDTCisSameAs<0,2>, SDTCisFP<0>, SDTCisPtrTy<1>
  243. ]>;
  244. def SDTAtomicStore : SDTypeProfile<0, 2, [
  245. SDTCisPtrTy<0>, SDTCisInt<1>
  246. ]>;
  247. def SDTAtomicLoad : SDTypeProfile<1, 1, [
  248. SDTCisInt<0>, SDTCisPtrTy<1>
  249. ]>;
  250. def SDTConvertOp : SDTypeProfile<1, 5, [ //cvtss, su, us, uu, ff, fs, fu, sf, su
  251. SDTCisVT<2, OtherVT>, SDTCisVT<3, OtherVT>, SDTCisPtrTy<4>, SDTCisPtrTy<5>
  252. ]>;
  253. class SDCallSeqStart<list<SDTypeConstraint> constraints> :
  254. SDTypeProfile<0, 2, constraints>;
  255. class SDCallSeqEnd<list<SDTypeConstraint> constraints> :
  256. SDTypeProfile<0, 2, constraints>;
  257. //===----------------------------------------------------------------------===//
  258. // Selection DAG Node definitions.
  259. //
  260. class SDNode<string opcode, SDTypeProfile typeprof,
  261. list<SDNodeProperty> props = [], string sdclass = "SDNode">
  262. : SDPatternOperator {
  263. string Opcode = opcode;
  264. string SDClass = sdclass;
  265. let Properties = props;
  266. SDTypeProfile TypeProfile = typeprof;
  267. }
  268. // Special TableGen-recognized dag nodes
  269. def set;
  270. def implicit;
  271. def node;
  272. def srcvalue;
  273. def imm : SDNode<"ISD::Constant" , SDTIntLeaf , [], "ConstantSDNode">;
  274. def timm : SDNode<"ISD::TargetConstant",SDTIntLeaf, [], "ConstantSDNode">;
  275. def fpimm : SDNode<"ISD::ConstantFP", SDTFPLeaf , [], "ConstantFPSDNode">;
  276. def vt : SDNode<"ISD::VALUETYPE" , SDTOther , [], "VTSDNode">;
  277. def bb : SDNode<"ISD::BasicBlock", SDTOther , [], "BasicBlockSDNode">;
  278. def cond : SDNode<"ISD::CONDCODE" , SDTOther , [], "CondCodeSDNode">;
  279. def undef : SDNode<"ISD::UNDEF" , SDTUNDEF , []>;
  280. def vscale : SDNode<"ISD::VSCALE" , SDTIntUnaryOp, []>;
  281. def globaladdr : SDNode<"ISD::GlobalAddress", SDTPtrLeaf, [],
  282. "GlobalAddressSDNode">;
  283. def tglobaladdr : SDNode<"ISD::TargetGlobalAddress", SDTPtrLeaf, [],
  284. "GlobalAddressSDNode">;
  285. def globaltlsaddr : SDNode<"ISD::GlobalTLSAddress", SDTPtrLeaf, [],
  286. "GlobalAddressSDNode">;
  287. def tglobaltlsaddr : SDNode<"ISD::TargetGlobalTLSAddress", SDTPtrLeaf, [],
  288. "GlobalAddressSDNode">;
  289. def constpool : SDNode<"ISD::ConstantPool", SDTPtrLeaf, [],
  290. "ConstantPoolSDNode">;
  291. def tconstpool : SDNode<"ISD::TargetConstantPool", SDTPtrLeaf, [],
  292. "ConstantPoolSDNode">;
  293. def jumptable : SDNode<"ISD::JumpTable", SDTPtrLeaf, [],
  294. "JumpTableSDNode">;
  295. def tjumptable : SDNode<"ISD::TargetJumpTable", SDTPtrLeaf, [],
  296. "JumpTableSDNode">;
  297. def frameindex : SDNode<"ISD::FrameIndex", SDTPtrLeaf, [],
  298. "FrameIndexSDNode">;
  299. def tframeindex : SDNode<"ISD::TargetFrameIndex", SDTPtrLeaf, [],
  300. "FrameIndexSDNode">;
  301. def externalsym : SDNode<"ISD::ExternalSymbol", SDTPtrLeaf, [],
  302. "ExternalSymbolSDNode">;
  303. def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [],
  304. "ExternalSymbolSDNode">;
  305. def mcsym: SDNode<"ISD::MCSymbol", SDTPtrLeaf, [], "MCSymbolSDNode">;
  306. def blockaddress : SDNode<"ISD::BlockAddress", SDTPtrLeaf, [],
  307. "BlockAddressSDNode">;
  308. def tblockaddress: SDNode<"ISD::TargetBlockAddress", SDTPtrLeaf, [],
  309. "BlockAddressSDNode">;
  310. def add : SDNode<"ISD::ADD" , SDTIntBinOp ,
  311. [SDNPCommutative, SDNPAssociative]>;
  312. def sub : SDNode<"ISD::SUB" , SDTIntBinOp>;
  313. def mul : SDNode<"ISD::MUL" , SDTIntBinOp,
  314. [SDNPCommutative, SDNPAssociative]>;
  315. def mulhs : SDNode<"ISD::MULHS" , SDTIntBinOp, [SDNPCommutative]>;
  316. def mulhu : SDNode<"ISD::MULHU" , SDTIntBinOp, [SDNPCommutative]>;
  317. def smullohi : SDNode<"ISD::SMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>;
  318. def umullohi : SDNode<"ISD::UMUL_LOHI" , SDTIntBinHiLoOp, [SDNPCommutative]>;
  319. def sdiv : SDNode<"ISD::SDIV" , SDTIntBinOp>;
  320. def udiv : SDNode<"ISD::UDIV" , SDTIntBinOp>;
  321. def srem : SDNode<"ISD::SREM" , SDTIntBinOp>;
  322. def urem : SDNode<"ISD::UREM" , SDTIntBinOp>;
  323. def sdivrem : SDNode<"ISD::SDIVREM" , SDTIntBinHiLoOp>;
  324. def udivrem : SDNode<"ISD::UDIVREM" , SDTIntBinHiLoOp>;
  325. def srl : SDNode<"ISD::SRL" , SDTIntShiftOp>;
  326. def sra : SDNode<"ISD::SRA" , SDTIntShiftOp>;
  327. def shl : SDNode<"ISD::SHL" , SDTIntShiftOp>;
  328. def rotl : SDNode<"ISD::ROTL" , SDTIntShiftOp>;
  329. def rotr : SDNode<"ISD::ROTR" , SDTIntShiftOp>;
  330. def fshl : SDNode<"ISD::FSHL" , SDTIntShiftDOp>;
  331. def fshr : SDNode<"ISD::FSHR" , SDTIntShiftDOp>;
  332. def and : SDNode<"ISD::AND" , SDTIntBinOp,
  333. [SDNPCommutative, SDNPAssociative]>;
  334. def or : SDNode<"ISD::OR" , SDTIntBinOp,
  335. [SDNPCommutative, SDNPAssociative]>;
  336. def xor : SDNode<"ISD::XOR" , SDTIntBinOp,
  337. [SDNPCommutative, SDNPAssociative]>;
  338. def addc : SDNode<"ISD::ADDC" , SDTIntBinOp,
  339. [SDNPCommutative, SDNPOutGlue]>;
  340. def adde : SDNode<"ISD::ADDE" , SDTIntBinOp,
  341. [SDNPCommutative, SDNPOutGlue, SDNPInGlue]>;
  342. def subc : SDNode<"ISD::SUBC" , SDTIntBinOp,
  343. [SDNPOutGlue]>;
  344. def sube : SDNode<"ISD::SUBE" , SDTIntBinOp,
  345. [SDNPOutGlue, SDNPInGlue]>;
  346. def smin : SDNode<"ISD::SMIN" , SDTIntBinOp,
  347. [SDNPCommutative, SDNPAssociative]>;
  348. def smax : SDNode<"ISD::SMAX" , SDTIntBinOp,
  349. [SDNPCommutative, SDNPAssociative]>;
  350. def umin : SDNode<"ISD::UMIN" , SDTIntBinOp,
  351. [SDNPCommutative, SDNPAssociative]>;
  352. def umax : SDNode<"ISD::UMAX" , SDTIntBinOp,
  353. [SDNPCommutative, SDNPAssociative]>;
  354. def saddsat : SDNode<"ISD::SADDSAT" , SDTIntBinOp, [SDNPCommutative]>;
  355. def uaddsat : SDNode<"ISD::UADDSAT" , SDTIntBinOp, [SDNPCommutative]>;
  356. def ssubsat : SDNode<"ISD::SSUBSAT" , SDTIntBinOp>;
  357. def usubsat : SDNode<"ISD::USUBSAT" , SDTIntBinOp>;
  358. def sshlsat : SDNode<"ISD::SSHLSAT" , SDTIntBinOp>;
  359. def ushlsat : SDNode<"ISD::USHLSAT" , SDTIntBinOp>;
  360. def smulfix : SDNode<"ISD::SMULFIX" , SDTIntScaledBinOp, [SDNPCommutative]>;
  361. def smulfixsat : SDNode<"ISD::SMULFIXSAT", SDTIntScaledBinOp, [SDNPCommutative]>;
  362. def umulfix : SDNode<"ISD::UMULFIX" , SDTIntScaledBinOp, [SDNPCommutative]>;
  363. def umulfixsat : SDNode<"ISD::UMULFIXSAT", SDTIntScaledBinOp, [SDNPCommutative]>;
  364. def sdivfix : SDNode<"ISD::SDIVFIX" , SDTIntScaledBinOp>;
  365. def sdivfixsat : SDNode<"ISD::SDIVFIXSAT", SDTIntScaledBinOp>;
  366. def udivfix : SDNode<"ISD::UDIVFIX" , SDTIntScaledBinOp>;
  367. def udivfixsat : SDNode<"ISD::UDIVFIXSAT", SDTIntScaledBinOp>;
  368. def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
  369. def sext_invec : SDNode<"ISD::SIGN_EXTEND_VECTOR_INREG", SDTExtInvec>;
  370. def zext_invec : SDNode<"ISD::ZERO_EXTEND_VECTOR_INREG", SDTExtInvec>;
  371. def abs : SDNode<"ISD::ABS" , SDTIntUnaryOp>;
  372. def bitreverse : SDNode<"ISD::BITREVERSE" , SDTIntUnaryOp>;
  373. def bswap : SDNode<"ISD::BSWAP" , SDTIntUnaryOp>;
  374. def ctlz : SDNode<"ISD::CTLZ" , SDTIntBitCountUnaryOp>;
  375. def cttz : SDNode<"ISD::CTTZ" , SDTIntBitCountUnaryOp>;
  376. def ctpop : SDNode<"ISD::CTPOP" , SDTIntBitCountUnaryOp>;
  377. def ctlz_zero_undef : SDNode<"ISD::CTLZ_ZERO_UNDEF", SDTIntBitCountUnaryOp>;
  378. def cttz_zero_undef : SDNode<"ISD::CTTZ_ZERO_UNDEF", SDTIntBitCountUnaryOp>;
  379. def sext : SDNode<"ISD::SIGN_EXTEND", SDTIntExtendOp>;
  380. def zext : SDNode<"ISD::ZERO_EXTEND", SDTIntExtendOp>;
  381. def anyext : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>;
  382. def trunc : SDNode<"ISD::TRUNCATE" , SDTIntTruncOp>;
  383. def bitconvert : SDNode<"ISD::BITCAST" , SDTUnaryOp>;
  384. def addrspacecast : SDNode<"ISD::ADDRSPACECAST", SDTUnaryOp>;
  385. def extractelt : SDNode<"ISD::EXTRACT_VECTOR_ELT", SDTVecExtract>;
  386. def insertelt : SDNode<"ISD::INSERT_VECTOR_ELT", SDTVecInsert>;
  387. def vecreduce_add : SDNode<"ISD::VECREDUCE_ADD", SDTVecReduce>;
  388. def vecreduce_smax : SDNode<"ISD::VECREDUCE_SMAX", SDTVecReduce>;
  389. def vecreduce_umax : SDNode<"ISD::VECREDUCE_UMAX", SDTVecReduce>;
  390. def vecreduce_smin : SDNode<"ISD::VECREDUCE_SMIN", SDTVecReduce>;
  391. def vecreduce_umin : SDNode<"ISD::VECREDUCE_UMIN", SDTVecReduce>;
  392. def vecreduce_fadd : SDNode<"ISD::VECREDUCE_FADD", SDTFPVecReduce>;
  393. def fadd : SDNode<"ISD::FADD" , SDTFPBinOp, [SDNPCommutative]>;
  394. def fsub : SDNode<"ISD::FSUB" , SDTFPBinOp>;
  395. def fmul : SDNode<"ISD::FMUL" , SDTFPBinOp, [SDNPCommutative]>;
  396. def fdiv : SDNode<"ISD::FDIV" , SDTFPBinOp>;
  397. def frem : SDNode<"ISD::FREM" , SDTFPBinOp>;
  398. def fma : SDNode<"ISD::FMA" , SDTFPTernaryOp, [SDNPCommutative]>;
  399. def fmad : SDNode<"ISD::FMAD" , SDTFPTernaryOp, [SDNPCommutative]>;
  400. def fabs : SDNode<"ISD::FABS" , SDTFPUnaryOp>;
  401. def fminnum : SDNode<"ISD::FMINNUM" , SDTFPBinOp,
  402. [SDNPCommutative, SDNPAssociative]>;
  403. def fmaxnum : SDNode<"ISD::FMAXNUM" , SDTFPBinOp,
  404. [SDNPCommutative, SDNPAssociative]>;
  405. def fminnum_ieee : SDNode<"ISD::FMINNUM_IEEE", SDTFPBinOp,
  406. [SDNPCommutative]>;
  407. def fmaxnum_ieee : SDNode<"ISD::FMAXNUM_IEEE", SDTFPBinOp,
  408. [SDNPCommutative]>;
  409. def fminimum : SDNode<"ISD::FMINIMUM" , SDTFPBinOp,
  410. [SDNPCommutative, SDNPAssociative]>;
  411. def fmaximum : SDNode<"ISD::FMAXIMUM" , SDTFPBinOp,
  412. [SDNPCommutative, SDNPAssociative]>;
  413. def fgetsign : SDNode<"ISD::FGETSIGN" , SDTFPToIntOp>;
  414. def fcanonicalize : SDNode<"ISD::FCANONICALIZE", SDTFPUnaryOp>;
  415. def fneg : SDNode<"ISD::FNEG" , SDTFPUnaryOp>;
  416. def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>;
  417. def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>;
  418. def fcos : SDNode<"ISD::FCOS" , SDTFPUnaryOp>;
  419. def fexp2 : SDNode<"ISD::FEXP2" , SDTFPUnaryOp>;
  420. def fpow : SDNode<"ISD::FPOW" , SDTFPBinOp>;
  421. def flog2 : SDNode<"ISD::FLOG2" , SDTFPUnaryOp>;
  422. def frint : SDNode<"ISD::FRINT" , SDTFPUnaryOp>;
  423. def ftrunc : SDNode<"ISD::FTRUNC" , SDTFPUnaryOp>;
  424. def fceil : SDNode<"ISD::FCEIL" , SDTFPUnaryOp>;
  425. def ffloor : SDNode<"ISD::FFLOOR" , SDTFPUnaryOp>;
  426. def fnearbyint : SDNode<"ISD::FNEARBYINT" , SDTFPUnaryOp>;
  427. def fround : SDNode<"ISD::FROUND" , SDTFPUnaryOp>;
  428. def lround : SDNode<"ISD::LROUND" , SDTFPToIntOp>;
  429. def llround : SDNode<"ISD::LLROUND" , SDTFPToIntOp>;
  430. def lrint : SDNode<"ISD::LRINT" , SDTFPToIntOp>;
  431. def llrint : SDNode<"ISD::LLRINT" , SDTFPToIntOp>;
  432. def fpround : SDNode<"ISD::FP_ROUND" , SDTFPRoundOp>;
  433. def fpextend : SDNode<"ISD::FP_EXTEND" , SDTFPExtendOp>;
  434. def fcopysign : SDNode<"ISD::FCOPYSIGN" , SDTFPSignOp>;
  435. def sint_to_fp : SDNode<"ISD::SINT_TO_FP" , SDTIntToFPOp>;
  436. def uint_to_fp : SDNode<"ISD::UINT_TO_FP" , SDTIntToFPOp>;
  437. def fp_to_sint : SDNode<"ISD::FP_TO_SINT" , SDTFPToIntOp>;
  438. def fp_to_uint : SDNode<"ISD::FP_TO_UINT" , SDTFPToIntOp>;
  439. def fp_to_sint_sat : SDNode<"ISD::FP_TO_SINT_SAT" , SDTFPToIntSatOp>;
  440. def fp_to_uint_sat : SDNode<"ISD::FP_TO_UINT_SAT" , SDTFPToIntSatOp>;
  441. def f16_to_fp : SDNode<"ISD::FP16_TO_FP" , SDTIntToFPOp>;
  442. def fp_to_f16 : SDNode<"ISD::FP_TO_FP16" , SDTFPToIntOp>;
  443. def strict_fadd : SDNode<"ISD::STRICT_FADD",
  444. SDTFPBinOp, [SDNPHasChain, SDNPCommutative]>;
  445. def strict_fsub : SDNode<"ISD::STRICT_FSUB",
  446. SDTFPBinOp, [SDNPHasChain]>;
  447. def strict_fmul : SDNode<"ISD::STRICT_FMUL",
  448. SDTFPBinOp, [SDNPHasChain, SDNPCommutative]>;
  449. def strict_fdiv : SDNode<"ISD::STRICT_FDIV",
  450. SDTFPBinOp, [SDNPHasChain]>;
  451. def strict_frem : SDNode<"ISD::STRICT_FREM",
  452. SDTFPBinOp, [SDNPHasChain]>;
  453. def strict_fma : SDNode<"ISD::STRICT_FMA",
  454. SDTFPTernaryOp, [SDNPHasChain, SDNPCommutative]>;
  455. def strict_fsqrt : SDNode<"ISD::STRICT_FSQRT",
  456. SDTFPUnaryOp, [SDNPHasChain]>;
  457. def strict_fsin : SDNode<"ISD::STRICT_FSIN",
  458. SDTFPUnaryOp, [SDNPHasChain]>;
  459. def strict_fcos : SDNode<"ISD::STRICT_FCOS",
  460. SDTFPUnaryOp, [SDNPHasChain]>;
  461. def strict_fexp2 : SDNode<"ISD::STRICT_FEXP2",
  462. SDTFPUnaryOp, [SDNPHasChain]>;
  463. def strict_fpow : SDNode<"ISD::STRICT_FPOW",
  464. SDTFPBinOp, [SDNPHasChain]>;
  465. def strict_flog2 : SDNode<"ISD::STRICT_FLOG2",
  466. SDTFPUnaryOp, [SDNPHasChain]>;
  467. def strict_frint : SDNode<"ISD::STRICT_FRINT",
  468. SDTFPUnaryOp, [SDNPHasChain]>;
  469. def strict_lrint : SDNode<"ISD::STRICT_LRINT",
  470. SDTFPToIntOp, [SDNPHasChain]>;
  471. def strict_llrint : SDNode<"ISD::STRICT_LLRINT",
  472. SDTFPToIntOp, [SDNPHasChain]>;
  473. def strict_fnearbyint : SDNode<"ISD::STRICT_FNEARBYINT",
  474. SDTFPUnaryOp, [SDNPHasChain]>;
  475. def strict_fceil : SDNode<"ISD::STRICT_FCEIL",
  476. SDTFPUnaryOp, [SDNPHasChain]>;
  477. def strict_ffloor : SDNode<"ISD::STRICT_FFLOOR",
  478. SDTFPUnaryOp, [SDNPHasChain]>;
  479. def strict_lround : SDNode<"ISD::STRICT_LROUND",
  480. SDTFPToIntOp, [SDNPHasChain]>;
  481. def strict_llround : SDNode<"ISD::STRICT_LLROUND",
  482. SDTFPToIntOp, [SDNPHasChain]>;
  483. def strict_fround : SDNode<"ISD::STRICT_FROUND",
  484. SDTFPUnaryOp, [SDNPHasChain]>;
  485. def strict_ftrunc : SDNode<"ISD::STRICT_FTRUNC",
  486. SDTFPUnaryOp, [SDNPHasChain]>;
  487. def strict_fminnum : SDNode<"ISD::STRICT_FMINNUM",
  488. SDTFPBinOp, [SDNPHasChain,
  489. SDNPCommutative, SDNPAssociative]>;
  490. def strict_fmaxnum : SDNode<"ISD::STRICT_FMAXNUM",
  491. SDTFPBinOp, [SDNPHasChain,
  492. SDNPCommutative, SDNPAssociative]>;
  493. def strict_fminimum : SDNode<"ISD::STRICT_FMINIMUM",
  494. SDTFPBinOp, [SDNPHasChain,
  495. SDNPCommutative, SDNPAssociative]>;
  496. def strict_fmaximum : SDNode<"ISD::STRICT_FMAXIMUM",
  497. SDTFPBinOp, [SDNPHasChain,
  498. SDNPCommutative, SDNPAssociative]>;
  499. def strict_fpround : SDNode<"ISD::STRICT_FP_ROUND",
  500. SDTFPRoundOp, [SDNPHasChain]>;
  501. def strict_fpextend : SDNode<"ISD::STRICT_FP_EXTEND",
  502. SDTFPExtendOp, [SDNPHasChain]>;
  503. def strict_fp_to_sint : SDNode<"ISD::STRICT_FP_TO_SINT",
  504. SDTFPToIntOp, [SDNPHasChain]>;
  505. def strict_fp_to_uint : SDNode<"ISD::STRICT_FP_TO_UINT",
  506. SDTFPToIntOp, [SDNPHasChain]>;
  507. def strict_sint_to_fp : SDNode<"ISD::STRICT_SINT_TO_FP",
  508. SDTIntToFPOp, [SDNPHasChain]>;
  509. def strict_uint_to_fp : SDNode<"ISD::STRICT_UINT_TO_FP",
  510. SDTIntToFPOp, [SDNPHasChain]>;
  511. def strict_fsetcc : SDNode<"ISD::STRICT_FSETCC", SDTSetCC, [SDNPHasChain]>;
  512. def strict_fsetccs : SDNode<"ISD::STRICT_FSETCCS", SDTSetCC, [SDNPHasChain]>;
  513. def setcc : SDNode<"ISD::SETCC" , SDTSetCC>;
  514. def select : SDNode<"ISD::SELECT" , SDTSelect>;
  515. def vselect : SDNode<"ISD::VSELECT" , SDTVSelect>;
  516. def selectcc : SDNode<"ISD::SELECT_CC" , SDTSelectCC>;
  517. def brcc : SDNode<"ISD::BR_CC" , SDTBrCC, [SDNPHasChain]>;
  518. def brcond : SDNode<"ISD::BRCOND" , SDTBrcond, [SDNPHasChain]>;
  519. def brind : SDNode<"ISD::BRIND" , SDTBrind, [SDNPHasChain]>;
  520. def br : SDNode<"ISD::BR" , SDTBr, [SDNPHasChain]>;
  521. def catchret : SDNode<"ISD::CATCHRET" , SDTCatchret,
  522. [SDNPHasChain, SDNPSideEffect]>;
  523. def cleanupret : SDNode<"ISD::CLEANUPRET" , SDTNone, [SDNPHasChain]>;
  524. def trap : SDNode<"ISD::TRAP" , SDTNone,
  525. [SDNPHasChain, SDNPSideEffect]>;
  526. def debugtrap : SDNode<"ISD::DEBUGTRAP" , SDTNone,
  527. [SDNPHasChain, SDNPSideEffect]>;
  528. def ubsantrap : SDNode<"ISD::UBSANTRAP" , SDTUBSANTrap,
  529. [SDNPHasChain, SDNPSideEffect]>;
  530. def prefetch : SDNode<"ISD::PREFETCH" , SDTPrefetch,
  531. [SDNPHasChain, SDNPMayLoad, SDNPMayStore,
  532. SDNPMemOperand]>;
  533. def readcyclecounter : SDNode<"ISD::READCYCLECOUNTER", SDTIntLeaf,
  534. [SDNPHasChain, SDNPSideEffect]>;
  535. def atomic_fence : SDNode<"ISD::ATOMIC_FENCE" , SDTAtomicFence,
  536. [SDNPHasChain, SDNPSideEffect]>;
  537. def atomic_cmp_swap : SDNode<"ISD::ATOMIC_CMP_SWAP" , SDTAtomic3,
  538. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  539. def atomic_load_add : SDNode<"ISD::ATOMIC_LOAD_ADD" , SDTAtomic2,
  540. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  541. def atomic_swap : SDNode<"ISD::ATOMIC_SWAP", SDTAtomic2,
  542. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  543. def atomic_load_sub : SDNode<"ISD::ATOMIC_LOAD_SUB" , SDTAtomic2,
  544. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  545. def atomic_load_and : SDNode<"ISD::ATOMIC_LOAD_AND" , SDTAtomic2,
  546. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  547. def atomic_load_clr : SDNode<"ISD::ATOMIC_LOAD_CLR" , SDTAtomic2,
  548. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  549. def atomic_load_or : SDNode<"ISD::ATOMIC_LOAD_OR" , SDTAtomic2,
  550. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  551. def atomic_load_xor : SDNode<"ISD::ATOMIC_LOAD_XOR" , SDTAtomic2,
  552. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  553. def atomic_load_nand: SDNode<"ISD::ATOMIC_LOAD_NAND", SDTAtomic2,
  554. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  555. def atomic_load_min : SDNode<"ISD::ATOMIC_LOAD_MIN", SDTAtomic2,
  556. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  557. def atomic_load_max : SDNode<"ISD::ATOMIC_LOAD_MAX", SDTAtomic2,
  558. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  559. def atomic_load_umin : SDNode<"ISD::ATOMIC_LOAD_UMIN", SDTAtomic2,
  560. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  561. def atomic_load_umax : SDNode<"ISD::ATOMIC_LOAD_UMAX", SDTAtomic2,
  562. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  563. def atomic_load_fadd : SDNode<"ISD::ATOMIC_LOAD_FADD" , SDTFPAtomic2,
  564. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  565. def atomic_load_fsub : SDNode<"ISD::ATOMIC_LOAD_FSUB" , SDTFPAtomic2,
  566. [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
  567. def atomic_load : SDNode<"ISD::ATOMIC_LOAD", SDTAtomicLoad,
  568. [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
  569. def atomic_store : SDNode<"ISD::ATOMIC_STORE", SDTAtomicStore,
  570. [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
  571. def masked_st : SDNode<"ISD::MSTORE", SDTMaskedStore,
  572. [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
  573. def masked_ld : SDNode<"ISD::MLOAD", SDTMaskedLoad,
  574. [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
  575. // Do not use ld, st directly. Use load, extload, sextload, zextload, store,
  576. // and truncst (see below).
  577. def ld : SDNode<"ISD::LOAD" , SDTLoad,
  578. [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
  579. def st : SDNode<"ISD::STORE" , SDTStore,
  580. [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
  581. def ist : SDNode<"ISD::STORE" , SDTIStore,
  582. [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
  583. def vector_shuffle : SDNode<"ISD::VECTOR_SHUFFLE", SDTVecShuffle, []>;
  584. def build_vector : SDNode<"ISD::BUILD_VECTOR", SDTypeProfile<1, -1, []>, []>;
  585. def splat_vector : SDNode<"ISD::SPLAT_VECTOR", SDTypeProfile<1, 1, []>, []>;
  586. def scalar_to_vector : SDNode<"ISD::SCALAR_TO_VECTOR", SDTypeProfile<1, 1, []>,
  587. []>;
  588. // vector_extract/vector_insert are deprecated. extractelt/insertelt
  589. // are preferred.
  590. def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT",
  591. SDTypeProfile<1, 2, [SDTCisPtrTy<2>]>, []>;
  592. def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT",
  593. SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>;
  594. def concat_vectors : SDNode<"ISD::CONCAT_VECTORS",
  595. SDTypeProfile<1, 2, [SDTCisSubVecOfVec<1, 0>, SDTCisSameAs<1, 2>]>,[]>;
  596. // This operator does not do subvector type checking. The ARM
  597. // backend, at least, needs it.
  598. def vector_extract_subvec : SDNode<"ISD::EXTRACT_SUBVECTOR",
  599. SDTypeProfile<1, 2, [SDTCisInt<2>, SDTCisVec<1>, SDTCisVec<0>]>,
  600. []>;
  601. // This operator does subvector type checking.
  602. def extract_subvector : SDNode<"ISD::EXTRACT_SUBVECTOR", SDTSubVecExtract, []>;
  603. def insert_subvector : SDNode<"ISD::INSERT_SUBVECTOR", SDTSubVecInsert, []>;
  604. // Nodes for intrinsics, you should use the intrinsic itself and let tblgen use
  605. // these internally. Don't reference these directly.
  606. def intrinsic_void : SDNode<"ISD::INTRINSIC_VOID",
  607. SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
  608. [SDNPHasChain]>;
  609. def intrinsic_w_chain : SDNode<"ISD::INTRINSIC_W_CHAIN",
  610. SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>,
  611. [SDNPHasChain]>;
  612. def intrinsic_wo_chain : SDNode<"ISD::INTRINSIC_WO_CHAIN",
  613. SDTypeProfile<1, -1, [SDTCisPtrTy<1>]>, []>;
  614. def SDT_assert : SDTypeProfile<1, 1,
  615. [SDTCisInt<0>, SDTCisInt<1>, SDTCisSameAs<1, 0>]>;
  616. def assertsext : SDNode<"ISD::AssertSext", SDT_assert>;
  617. def assertzext : SDNode<"ISD::AssertZext", SDT_assert>;
  618. def assertalign : SDNode<"ISD::AssertAlign", SDT_assert>;
  619. //===----------------------------------------------------------------------===//
  620. // Selection DAG Condition Codes
  621. class CondCode<string fcmpName = "", string icmpName = ""> {
  622. string ICmpPredicate = icmpName;
  623. string FCmpPredicate = fcmpName;
  624. }
  625. // ISD::CondCode enums, and mapping to CmpInst::Predicate names
  626. def SETOEQ : CondCode<"FCMP_OEQ">;
  627. def SETOGT : CondCode<"FCMP_OGT">;
  628. def SETOGE : CondCode<"FCMP_OGE">;
  629. def SETOLT : CondCode<"FCMP_OLT">;
  630. def SETOLE : CondCode<"FCMP_OLE">;
  631. def SETONE : CondCode<"FCMP_ONE">;
  632. def SETO : CondCode<"FCMP_ORD">;
  633. def SETUO : CondCode<"FCMP_UNO">;
  634. def SETUEQ : CondCode<"FCMP_UEQ">;
  635. def SETUGT : CondCode<"FCMP_UGT", "ICMP_UGT">;
  636. def SETUGE : CondCode<"FCMP_UGE", "ICMP_UGE">;
  637. def SETULT : CondCode<"FCMP_ULT", "ICMP_ULT">;
  638. def SETULE : CondCode<"FCMP_ULE", "ICMP_ULE">;
  639. def SETUNE : CondCode<"FCMP_UNE">;
  640. def SETEQ : CondCode<"", "ICMP_EQ">;
  641. def SETGT : CondCode<"", "ICMP_SGT">;
  642. def SETGE : CondCode<"", "ICMP_SGE">;
  643. def SETLT : CondCode<"", "ICMP_SLT">;
  644. def SETLE : CondCode<"", "ICMP_SLE">;
  645. def SETNE : CondCode<"", "ICMP_NE">;
  646. //===----------------------------------------------------------------------===//
  647. // Selection DAG Node Transformation Functions.
  648. //
  649. // This mechanism allows targets to manipulate nodes in the output DAG once a
  650. // match has been formed. This is typically used to manipulate immediate
  651. // values.
  652. //
  653. class SDNodeXForm<SDNode opc, code xformFunction> {
  654. SDNode Opcode = opc;
  655. code XFormFunction = xformFunction;
  656. }
  657. def NOOP_SDNodeXForm : SDNodeXForm<imm, [{}]>;
  658. //===----------------------------------------------------------------------===//
  659. // Selection DAG Pattern Fragments.
  660. //
  661. // Pattern fragments are reusable chunks of dags that match specific things.
  662. // They can take arguments and have C++ predicates that control whether they
  663. // match. They are intended to make the patterns for common instructions more
  664. // compact and readable.
  665. //
  666. /// PatFrags - Represents a set of pattern fragments. Each single fragment
  667. /// can match something on the DAG, from a single node to multiple nested other
  668. /// fragments. The whole set of fragments matches if any of the single
  669. /// fragments match. This allows e.g. matching and "add with overflow" and
  670. /// a regular "add" with the same fragment set.
  671. ///
  672. class PatFrags<dag ops, list<dag> frags, code pred = [{}],
  673. SDNodeXForm xform = NOOP_SDNodeXForm> : SDPatternOperator {
  674. dag Operands = ops;
  675. list<dag> Fragments = frags;
  676. code PredicateCode = pred;
  677. code GISelPredicateCode = [{}];
  678. code ImmediateCode = [{}];
  679. SDNodeXForm OperandTransform = xform;
  680. // When this is set, the PredicateCode may refer to a constant Operands
  681. // vector which contains the captured nodes of the DAG, in the order listed
  682. // by the Operands field above.
  683. //
  684. // This is useful when Fragments involves associative / commutative
  685. // operators: a single piece of code can easily refer to all operands even
  686. // when re-associated / commuted variants of the fragment are matched.
  687. bit PredicateCodeUsesOperands = false;
  688. // Define a few pre-packaged predicates. This helps GlobalISel import
  689. // existing rules from SelectionDAG for many common cases.
  690. // They will be tested prior to the code in pred and must not be used in
  691. // ImmLeaf and its subclasses.
  692. // Is the desired pre-packaged predicate for a load?
  693. bit IsLoad = ?;
  694. // Is the desired pre-packaged predicate for a store?
  695. bit IsStore = ?;
  696. // Is the desired pre-packaged predicate for an atomic?
  697. bit IsAtomic = ?;
  698. // cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
  699. // cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
  700. bit IsUnindexed = ?;
  701. // cast<LoadSDNode>(N)->getExtensionType() != ISD::NON_EXTLOAD
  702. bit IsNonExtLoad = ?;
  703. // cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
  704. bit IsAnyExtLoad = ?;
  705. // cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
  706. bit IsSignExtLoad = ?;
  707. // cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
  708. bit IsZeroExtLoad = ?;
  709. // !cast<StoreSDNode>(N)->isTruncatingStore();
  710. // cast<StoreSDNode>(N)->isTruncatingStore();
  711. bit IsTruncStore = ?;
  712. // cast<MemSDNode>(N)->getAddressSpace() ==
  713. // If this empty, accept any address space.
  714. list<int> AddressSpaces = ?;
  715. // cast<MemSDNode>(N)->getAlignment() >=
  716. // If this is empty, accept any alignment.
  717. int MinAlignment = ?;
  718. // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::Monotonic
  719. bit IsAtomicOrderingMonotonic = ?;
  720. // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::Acquire
  721. bit IsAtomicOrderingAcquire = ?;
  722. // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::Release
  723. bit IsAtomicOrderingRelease = ?;
  724. // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::AcquireRelease
  725. bit IsAtomicOrderingAcquireRelease = ?;
  726. // cast<AtomicSDNode>(N)->getOrdering() == AtomicOrdering::SequentiallyConsistent
  727. bit IsAtomicOrderingSequentiallyConsistent = ?;
  728. // isAcquireOrStronger(cast<AtomicSDNode>(N)->getOrdering())
  729. // !isAcquireOrStronger(cast<AtomicSDNode>(N)->getOrdering())
  730. bit IsAtomicOrderingAcquireOrStronger = ?;
  731. // isReleaseOrStronger(cast<AtomicSDNode>(N)->getOrdering())
  732. // !isReleaseOrStronger(cast<AtomicSDNode>(N)->getOrdering())
  733. bit IsAtomicOrderingReleaseOrStronger = ?;
  734. // cast<LoadSDNode>(N)->getMemoryVT() == MVT::<VT>;
  735. // cast<StoreSDNode>(N)->getMemoryVT() == MVT::<VT>;
  736. ValueType MemoryVT = ?;
  737. // cast<LoadSDNode>(N)->getMemoryVT().getScalarType() == MVT::<VT>;
  738. // cast<StoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::<VT>;
  739. ValueType ScalarMemoryVT = ?;
  740. }
  741. // PatFrag - A version of PatFrags matching only a single fragment.
  742. class PatFrag<dag ops, dag frag, code pred = [{}],
  743. SDNodeXForm xform = NOOP_SDNodeXForm>
  744. : PatFrags<ops, [frag], pred, xform>;
  745. // OutPatFrag is a pattern fragment that is used as part of an output pattern
  746. // (not an input pattern). These do not have predicates or transforms, but are
  747. // used to avoid repeated subexpressions in output patterns.
  748. class OutPatFrag<dag ops, dag frag>
  749. : PatFrag<ops, frag, [{}], NOOP_SDNodeXForm>;
  750. // PatLeaf's are pattern fragments that have no operands. This is just a helper
  751. // to define immediates and other common things concisely.
  752. class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
  753. : PatFrag<(ops), frag, pred, xform>;
  754. // ImmLeaf is a pattern fragment with a constraint on the immediate. The
  755. // constraint is a function that is run on the immediate (always with the value
  756. // sign extended out to an int64_t) as Imm. For example:
  757. //
  758. // def immSExt8 : ImmLeaf<i16, [{ return (char)Imm == Imm; }]>;
  759. //
  760. // this is a more convenient form to match 'imm' nodes in than PatLeaf and also
  761. // is preferred over using PatLeaf because it allows the code generator to
  762. // reason more about the constraint.
  763. //
  764. // If FastIsel should ignore all instructions that have an operand of this type,
  765. // the FastIselShouldIgnore flag can be set. This is an optimization to reduce
  766. // the code size of the generated fast instruction selector.
  767. class ImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm,
  768. SDNode ImmNode = imm>
  769. : PatFrag<(ops), (vt ImmNode), [{}], xform> {
  770. let ImmediateCode = pred;
  771. bit FastIselShouldIgnore = false;
  772. // Is the data type of the immediate an APInt?
  773. bit IsAPInt = false;
  774. // Is the data type of the immediate an APFloat?
  775. bit IsAPFloat = false;
  776. }
  777. // Convenience wrapper for ImmLeaf to use timm/TargetConstant instead
  778. // of imm/Constant.
  779. class TImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm,
  780. SDNode ImmNode = timm> : ImmLeaf<vt, pred, xform, ImmNode>;
  781. // An ImmLeaf except that Imm is an APInt. This is useful when you need to
  782. // zero-extend the immediate instead of sign-extend it.
  783. //
  784. // Note that FastISel does not currently understand IntImmLeaf and will not
  785. // generate code for rules that make use of it. As such, it does not make sense
  786. // to replace ImmLeaf with IntImmLeaf. However, replacing PatLeaf with an
  787. // IntImmLeaf will allow GlobalISel to import the rule.
  788. class IntImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm>
  789. : ImmLeaf<vt, pred, xform> {
  790. let IsAPInt = true;
  791. let FastIselShouldIgnore = true;
  792. }
  793. // An ImmLeaf except that Imm is an APFloat.
  794. //
  795. // Note that FastISel does not currently understand FPImmLeaf and will not
  796. // generate code for rules that make use of it.
  797. class FPImmLeaf<ValueType vt, code pred, SDNodeXForm xform = NOOP_SDNodeXForm>
  798. : ImmLeaf<vt, pred, xform, fpimm> {
  799. let IsAPFloat = true;
  800. let FastIselShouldIgnore = true;
  801. }
  802. // Leaf fragments.
  803. def vtInt : PatLeaf<(vt), [{ return N->getVT().isInteger(); }]>;
  804. def vtFP : PatLeaf<(vt), [{ return N->getVT().isFloatingPoint(); }]>;
  805. // Use ISD::isConstantSplatVectorAllOnes or ISD::isConstantSplatVectorAllZeros
  806. // to look for the corresponding build_vector or splat_vector. Will look through
  807. // bitcasts and check for either opcode, except when used as a pattern root.
  808. // When used as a pattern root, only fixed-length build_vector and scalable
  809. // splat_vector are supported.
  810. def immAllOnesV; // ISD::isConstantSplatVectorAllOnes
  811. def immAllZerosV; // ISD::isConstantSplatVectorAllZeros
  812. // Other helper fragments.
  813. def not : PatFrag<(ops node:$in), (xor node:$in, -1)>;
  814. def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>;
  815. def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;
  816. def zanyext : PatFrags<(ops node:$op),
  817. [(zext node:$op),
  818. (anyext node:$op)]>;
  819. // null_frag - The null pattern operator is used in multiclass instantiations
  820. // which accept an SDPatternOperator for use in matching patterns for internal
  821. // definitions. When expanding a pattern, if the null fragment is referenced
  822. // in the expansion, the pattern is discarded and it is as-if '[]' had been
  823. // specified. This allows multiclasses to have the isel patterns be optional.
  824. def null_frag : SDPatternOperator;
  825. // load fragments.
  826. def unindexedload : PatFrag<(ops node:$ptr), (ld node:$ptr)> {
  827. let IsLoad = true;
  828. let IsUnindexed = true;
  829. }
  830. def load : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
  831. let IsLoad = true;
  832. let IsNonExtLoad = true;
  833. }
  834. // extending load fragments.
  835. def extload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
  836. let IsLoad = true;
  837. let IsAnyExtLoad = true;
  838. }
  839. def sextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
  840. let IsLoad = true;
  841. let IsSignExtLoad = true;
  842. }
  843. def zextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr)> {
  844. let IsLoad = true;
  845. let IsZeroExtLoad = true;
  846. }
  847. def extloadi1 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  848. let IsLoad = true;
  849. let MemoryVT = i1;
  850. }
  851. def extloadi8 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  852. let IsLoad = true;
  853. let MemoryVT = i8;
  854. }
  855. def extloadi16 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  856. let IsLoad = true;
  857. let MemoryVT = i16;
  858. }
  859. def extloadi32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  860. let IsLoad = true;
  861. let MemoryVT = i32;
  862. }
  863. def extloadf16 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  864. let IsLoad = true;
  865. let MemoryVT = f16;
  866. }
  867. def extloadf32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  868. let IsLoad = true;
  869. let MemoryVT = f32;
  870. }
  871. def extloadf64 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  872. let IsLoad = true;
  873. let MemoryVT = f64;
  874. }
  875. def sextloadi1 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
  876. let IsLoad = true;
  877. let MemoryVT = i1;
  878. }
  879. def sextloadi8 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
  880. let IsLoad = true;
  881. let MemoryVT = i8;
  882. }
  883. def sextloadi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
  884. let IsLoad = true;
  885. let MemoryVT = i16;
  886. }
  887. def sextloadi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
  888. let IsLoad = true;
  889. let MemoryVT = i32;
  890. }
  891. def zextloadi1 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
  892. let IsLoad = true;
  893. let MemoryVT = i1;
  894. }
  895. def zextloadi8 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
  896. let IsLoad = true;
  897. let MemoryVT = i8;
  898. }
  899. def zextloadi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
  900. let IsLoad = true;
  901. let MemoryVT = i16;
  902. }
  903. def zextloadi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
  904. let IsLoad = true;
  905. let MemoryVT = i32;
  906. }
  907. def extloadvi1 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  908. let IsLoad = true;
  909. let ScalarMemoryVT = i1;
  910. }
  911. def extloadvi8 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  912. let IsLoad = true;
  913. let ScalarMemoryVT = i8;
  914. }
  915. def extloadvi16 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  916. let IsLoad = true;
  917. let ScalarMemoryVT = i16;
  918. }
  919. def extloadvi32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  920. let IsLoad = true;
  921. let ScalarMemoryVT = i32;
  922. }
  923. def extloadvf32 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  924. let IsLoad = true;
  925. let ScalarMemoryVT = f32;
  926. }
  927. def extloadvf64 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
  928. let IsLoad = true;
  929. let ScalarMemoryVT = f64;
  930. }
  931. def sextloadvi1 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
  932. let IsLoad = true;
  933. let ScalarMemoryVT = i1;
  934. }
  935. def sextloadvi8 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
  936. let IsLoad = true;
  937. let ScalarMemoryVT = i8;
  938. }
  939. def sextloadvi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
  940. let IsLoad = true;
  941. let ScalarMemoryVT = i16;
  942. }
  943. def sextloadvi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr)> {
  944. let IsLoad = true;
  945. let ScalarMemoryVT = i32;
  946. }
  947. def zextloadvi1 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
  948. let IsLoad = true;
  949. let ScalarMemoryVT = i1;
  950. }
  951. def zextloadvi8 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
  952. let IsLoad = true;
  953. let ScalarMemoryVT = i8;
  954. }
  955. def zextloadvi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
  956. let IsLoad = true;
  957. let ScalarMemoryVT = i16;
  958. }
  959. def zextloadvi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr)> {
  960. let IsLoad = true;
  961. let ScalarMemoryVT = i32;
  962. }
  963. // store fragments.
  964. def unindexedstore : PatFrag<(ops node:$val, node:$ptr),
  965. (st node:$val, node:$ptr)> {
  966. let IsStore = true;
  967. let IsUnindexed = true;
  968. }
  969. def store : PatFrag<(ops node:$val, node:$ptr),
  970. (unindexedstore node:$val, node:$ptr)> {
  971. let IsStore = true;
  972. let IsTruncStore = false;
  973. }
  974. // truncstore fragments.
  975. def truncstore : PatFrag<(ops node:$val, node:$ptr),
  976. (unindexedstore node:$val, node:$ptr)> {
  977. let IsStore = true;
  978. let IsTruncStore = true;
  979. }
  980. def truncstorei8 : PatFrag<(ops node:$val, node:$ptr),
  981. (truncstore node:$val, node:$ptr)> {
  982. let IsStore = true;
  983. let MemoryVT = i8;
  984. }
  985. def truncstorei16 : PatFrag<(ops node:$val, node:$ptr),
  986. (truncstore node:$val, node:$ptr)> {
  987. let IsStore = true;
  988. let MemoryVT = i16;
  989. }
  990. def truncstorei32 : PatFrag<(ops node:$val, node:$ptr),
  991. (truncstore node:$val, node:$ptr)> {
  992. let IsStore = true;
  993. let MemoryVT = i32;
  994. }
  995. def truncstoref16 : PatFrag<(ops node:$val, node:$ptr),
  996. (truncstore node:$val, node:$ptr)> {
  997. let IsStore = true;
  998. let MemoryVT = f16;
  999. }
  1000. def truncstoref32 : PatFrag<(ops node:$val, node:$ptr),
  1001. (truncstore node:$val, node:$ptr)> {
  1002. let IsStore = true;
  1003. let MemoryVT = f32;
  1004. }
  1005. def truncstoref64 : PatFrag<(ops node:$val, node:$ptr),
  1006. (truncstore node:$val, node:$ptr)> {
  1007. let IsStore = true;
  1008. let MemoryVT = f64;
  1009. }
  1010. def truncstorevi8 : PatFrag<(ops node:$val, node:$ptr),
  1011. (truncstore node:$val, node:$ptr)> {
  1012. let IsStore = true;
  1013. let ScalarMemoryVT = i8;
  1014. }
  1015. def truncstorevi16 : PatFrag<(ops node:$val, node:$ptr),
  1016. (truncstore node:$val, node:$ptr)> {
  1017. let IsStore = true;
  1018. let ScalarMemoryVT = i16;
  1019. }
  1020. def truncstorevi32 : PatFrag<(ops node:$val, node:$ptr),
  1021. (truncstore node:$val, node:$ptr)> {
  1022. let IsStore = true;
  1023. let ScalarMemoryVT = i32;
  1024. }
  1025. // indexed store fragments.
  1026. def istore : PatFrag<(ops node:$val, node:$base, node:$offset),
  1027. (ist node:$val, node:$base, node:$offset)> {
  1028. let IsStore = true;
  1029. let IsTruncStore = false;
  1030. }
  1031. def pre_store : PatFrag<(ops node:$val, node:$base, node:$offset),
  1032. (istore node:$val, node:$base, node:$offset), [{
  1033. ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
  1034. return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
  1035. }]>;
  1036. def itruncstore : PatFrag<(ops node:$val, node:$base, node:$offset),
  1037. (ist node:$val, node:$base, node:$offset)> {
  1038. let IsStore = true;
  1039. let IsTruncStore = true;
  1040. }
  1041. def pre_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
  1042. (itruncstore node:$val, node:$base, node:$offset), [{
  1043. ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
  1044. return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
  1045. }]>;
  1046. def pre_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1047. (pre_truncst node:$val, node:$base, node:$offset)> {
  1048. let IsStore = true;
  1049. let MemoryVT = i1;
  1050. }
  1051. def pre_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1052. (pre_truncst node:$val, node:$base, node:$offset)> {
  1053. let IsStore = true;
  1054. let MemoryVT = i8;
  1055. }
  1056. def pre_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1057. (pre_truncst node:$val, node:$base, node:$offset)> {
  1058. let IsStore = true;
  1059. let MemoryVT = i16;
  1060. }
  1061. def pre_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1062. (pre_truncst node:$val, node:$base, node:$offset)> {
  1063. let IsStore = true;
  1064. let MemoryVT = i32;
  1065. }
  1066. def pre_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1067. (pre_truncst node:$val, node:$base, node:$offset)> {
  1068. let IsStore = true;
  1069. let MemoryVT = f32;
  1070. }
  1071. def pre_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1072. (pre_truncst node:$val, node:$base, node:$offset)> {
  1073. let IsStore = true;
  1074. let ScalarMemoryVT = i8;
  1075. }
  1076. def pre_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1077. (pre_truncst node:$val, node:$base, node:$offset)> {
  1078. let IsStore = true;
  1079. let ScalarMemoryVT = i16;
  1080. }
  1081. def post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
  1082. (istore node:$val, node:$ptr, node:$offset), [{
  1083. ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
  1084. return AM == ISD::POST_INC || AM == ISD::POST_DEC;
  1085. }]>;
  1086. def post_truncst : PatFrag<(ops node:$val, node:$base, node:$offset),
  1087. (itruncstore node:$val, node:$base, node:$offset), [{
  1088. ISD::MemIndexedMode AM = cast<StoreSDNode>(N)->getAddressingMode();
  1089. return AM == ISD::POST_INC || AM == ISD::POST_DEC;
  1090. }]>;
  1091. def post_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1092. (post_truncst node:$val, node:$base, node:$offset)> {
  1093. let IsStore = true;
  1094. let MemoryVT = i1;
  1095. }
  1096. def post_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1097. (post_truncst node:$val, node:$base, node:$offset)> {
  1098. let IsStore = true;
  1099. let MemoryVT = i8;
  1100. }
  1101. def post_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1102. (post_truncst node:$val, node:$base, node:$offset)> {
  1103. let IsStore = true;
  1104. let MemoryVT = i16;
  1105. }
  1106. def post_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1107. (post_truncst node:$val, node:$base, node:$offset)> {
  1108. let IsStore = true;
  1109. let MemoryVT = i32;
  1110. }
  1111. def post_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1112. (post_truncst node:$val, node:$base, node:$offset)> {
  1113. let IsStore = true;
  1114. let MemoryVT = f32;
  1115. }
  1116. def post_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1117. (post_truncst node:$val, node:$base, node:$offset)> {
  1118. let IsStore = true;
  1119. let ScalarMemoryVT = i8;
  1120. }
  1121. def post_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
  1122. (post_truncst node:$val, node:$base, node:$offset)> {
  1123. let IsStore = true;
  1124. let ScalarMemoryVT = i16;
  1125. }
  1126. // TODO: Split these into volatile and unordered flavors to enable
  1127. // selectively legal optimizations for each. (See D66309)
  1128. def simple_load : PatFrag<(ops node:$ptr),
  1129. (load node:$ptr), [{
  1130. return cast<LoadSDNode>(N)->isSimple();
  1131. }]>;
  1132. def simple_store : PatFrag<(ops node:$val, node:$ptr),
  1133. (store node:$val, node:$ptr), [{
  1134. return cast<StoreSDNode>(N)->isSimple();
  1135. }]>;
  1136. // nontemporal store fragments.
  1137. def nontemporalstore : PatFrag<(ops node:$val, node:$ptr),
  1138. (store node:$val, node:$ptr), [{
  1139. return cast<StoreSDNode>(N)->isNonTemporal();
  1140. }]>;
  1141. def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
  1142. (nontemporalstore node:$val, node:$ptr), [{
  1143. StoreSDNode *St = cast<StoreSDNode>(N);
  1144. return St->getAlignment() >= St->getMemoryVT().getStoreSize();
  1145. }]>;
  1146. def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr),
  1147. (nontemporalstore node:$val, node:$ptr), [{
  1148. StoreSDNode *St = cast<StoreSDNode>(N);
  1149. return St->getAlignment() < St->getMemoryVT().getStoreSize();
  1150. }]>;
  1151. // nontemporal load fragments.
  1152. def nontemporalload : PatFrag<(ops node:$ptr),
  1153. (load node:$ptr), [{
  1154. return cast<LoadSDNode>(N)->isNonTemporal();
  1155. }]>;
  1156. def alignednontemporalload : PatFrag<(ops node:$ptr),
  1157. (nontemporalload node:$ptr), [{
  1158. LoadSDNode *Ld = cast<LoadSDNode>(N);
  1159. return Ld->getAlignment() >= Ld->getMemoryVT().getStoreSize();
  1160. }]>;
  1161. // setcc convenience fragments.
  1162. def setoeq : PatFrag<(ops node:$lhs, node:$rhs),
  1163. (setcc node:$lhs, node:$rhs, SETOEQ)>;
  1164. def setogt : PatFrag<(ops node:$lhs, node:$rhs),
  1165. (setcc node:$lhs, node:$rhs, SETOGT)>;
  1166. def setoge : PatFrag<(ops node:$lhs, node:$rhs),
  1167. (setcc node:$lhs, node:$rhs, SETOGE)>;
  1168. def setolt : PatFrag<(ops node:$lhs, node:$rhs),
  1169. (setcc node:$lhs, node:$rhs, SETOLT)>;
  1170. def setole : PatFrag<(ops node:$lhs, node:$rhs),
  1171. (setcc node:$lhs, node:$rhs, SETOLE)>;
  1172. def setone : PatFrag<(ops node:$lhs, node:$rhs),
  1173. (setcc node:$lhs, node:$rhs, SETONE)>;
  1174. def seto : PatFrag<(ops node:$lhs, node:$rhs),
  1175. (setcc node:$lhs, node:$rhs, SETO)>;
  1176. def setuo : PatFrag<(ops node:$lhs, node:$rhs),
  1177. (setcc node:$lhs, node:$rhs, SETUO)>;
  1178. def setueq : PatFrag<(ops node:$lhs, node:$rhs),
  1179. (setcc node:$lhs, node:$rhs, SETUEQ)>;
  1180. def setugt : PatFrag<(ops node:$lhs, node:$rhs),
  1181. (setcc node:$lhs, node:$rhs, SETUGT)>;
  1182. def setuge : PatFrag<(ops node:$lhs, node:$rhs),
  1183. (setcc node:$lhs, node:$rhs, SETUGE)>;
  1184. def setult : PatFrag<(ops node:$lhs, node:$rhs),
  1185. (setcc node:$lhs, node:$rhs, SETULT)>;
  1186. def setule : PatFrag<(ops node:$lhs, node:$rhs),
  1187. (setcc node:$lhs, node:$rhs, SETULE)>;
  1188. def setune : PatFrag<(ops node:$lhs, node:$rhs),
  1189. (setcc node:$lhs, node:$rhs, SETUNE)>;
  1190. def seteq : PatFrag<(ops node:$lhs, node:$rhs),
  1191. (setcc node:$lhs, node:$rhs, SETEQ)>;
  1192. def setgt : PatFrag<(ops node:$lhs, node:$rhs),
  1193. (setcc node:$lhs, node:$rhs, SETGT)>;
  1194. def setge : PatFrag<(ops node:$lhs, node:$rhs),
  1195. (setcc node:$lhs, node:$rhs, SETGE)>;
  1196. def setlt : PatFrag<(ops node:$lhs, node:$rhs),
  1197. (setcc node:$lhs, node:$rhs, SETLT)>;
  1198. def setle : PatFrag<(ops node:$lhs, node:$rhs),
  1199. (setcc node:$lhs, node:$rhs, SETLE)>;
  1200. def setne : PatFrag<(ops node:$lhs, node:$rhs),
  1201. (setcc node:$lhs, node:$rhs, SETNE)>;
  1202. // We don't have strict FP extended loads as single DAG nodes, but we can
  1203. // still provide convenience fragments to match those operations.
  1204. def strict_extloadf32 : PatFrag<(ops node:$ptr),
  1205. (strict_fpextend (f32 (load node:$ptr)))>;
  1206. def strict_extloadf64 : PatFrag<(ops node:$ptr),
  1207. (strict_fpextend (f64 (load node:$ptr)))>;
  1208. // Convenience fragments to match both strict and non-strict fp operations
  1209. def any_fadd : PatFrags<(ops node:$lhs, node:$rhs),
  1210. [(strict_fadd node:$lhs, node:$rhs),
  1211. (fadd node:$lhs, node:$rhs)]>;
  1212. def any_fsub : PatFrags<(ops node:$lhs, node:$rhs),
  1213. [(strict_fsub node:$lhs, node:$rhs),
  1214. (fsub node:$lhs, node:$rhs)]>;
  1215. def any_fmul : PatFrags<(ops node:$lhs, node:$rhs),
  1216. [(strict_fmul node:$lhs, node:$rhs),
  1217. (fmul node:$lhs, node:$rhs)]>;
  1218. def any_fdiv : PatFrags<(ops node:$lhs, node:$rhs),
  1219. [(strict_fdiv node:$lhs, node:$rhs),
  1220. (fdiv node:$lhs, node:$rhs)]>;
  1221. def any_frem : PatFrags<(ops node:$lhs, node:$rhs),
  1222. [(strict_frem node:$lhs, node:$rhs),
  1223. (frem node:$lhs, node:$rhs)]>;
  1224. def any_fma : PatFrags<(ops node:$src1, node:$src2, node:$src3),
  1225. [(strict_fma node:$src1, node:$src2, node:$src3),
  1226. (fma node:$src1, node:$src2, node:$src3)]>;
  1227. def any_fsqrt : PatFrags<(ops node:$src),
  1228. [(strict_fsqrt node:$src),
  1229. (fsqrt node:$src)]>;
  1230. def any_fsin : PatFrags<(ops node:$src),
  1231. [(strict_fsin node:$src),
  1232. (fsin node:$src)]>;
  1233. def any_fcos : PatFrags<(ops node:$src),
  1234. [(strict_fcos node:$src),
  1235. (fcos node:$src)]>;
  1236. def any_fexp2 : PatFrags<(ops node:$src),
  1237. [(strict_fexp2 node:$src),
  1238. (fexp2 node:$src)]>;
  1239. def any_fpow : PatFrags<(ops node:$lhs, node:$rhs),
  1240. [(strict_fpow node:$lhs, node:$rhs),
  1241. (fpow node:$lhs, node:$rhs)]>;
  1242. def any_flog2 : PatFrags<(ops node:$src),
  1243. [(strict_flog2 node:$src),
  1244. (flog2 node:$src)]>;
  1245. def any_frint : PatFrags<(ops node:$src),
  1246. [(strict_frint node:$src),
  1247. (frint node:$src)]>;
  1248. def any_lrint : PatFrags<(ops node:$src),
  1249. [(strict_lrint node:$src),
  1250. (lrint node:$src)]>;
  1251. def any_llrint : PatFrags<(ops node:$src),
  1252. [(strict_llrint node:$src),
  1253. (llrint node:$src)]>;
  1254. def any_fnearbyint : PatFrags<(ops node:$src),
  1255. [(strict_fnearbyint node:$src),
  1256. (fnearbyint node:$src)]>;
  1257. def any_fceil : PatFrags<(ops node:$src),
  1258. [(strict_fceil node:$src),
  1259. (fceil node:$src)]>;
  1260. def any_ffloor : PatFrags<(ops node:$src),
  1261. [(strict_ffloor node:$src),
  1262. (ffloor node:$src)]>;
  1263. def any_lround : PatFrags<(ops node:$src),
  1264. [(strict_lround node:$src),
  1265. (lround node:$src)]>;
  1266. def any_llround : PatFrags<(ops node:$src),
  1267. [(strict_llround node:$src),
  1268. (llround node:$src)]>;
  1269. def any_fround : PatFrags<(ops node:$src),
  1270. [(strict_fround node:$src),
  1271. (fround node:$src)]>;
  1272. def any_ftrunc : PatFrags<(ops node:$src),
  1273. [(strict_ftrunc node:$src),
  1274. (ftrunc node:$src)]>;
  1275. def any_fmaxnum : PatFrags<(ops node:$lhs, node:$rhs),
  1276. [(strict_fmaxnum node:$lhs, node:$rhs),
  1277. (fmaxnum node:$lhs, node:$rhs)]>;
  1278. def any_fminnum : PatFrags<(ops node:$lhs, node:$rhs),
  1279. [(strict_fminnum node:$lhs, node:$rhs),
  1280. (fminnum node:$lhs, node:$rhs)]>;
  1281. def any_fmaximum : PatFrags<(ops node:$lhs, node:$rhs),
  1282. [(strict_fmaximum node:$lhs, node:$rhs),
  1283. (fmaximum node:$lhs, node:$rhs)]>;
  1284. def any_fminimum : PatFrags<(ops node:$lhs, node:$rhs),
  1285. [(strict_fminimum node:$lhs, node:$rhs),
  1286. (fminimum node:$lhs, node:$rhs)]>;
  1287. def any_fpround : PatFrags<(ops node:$src),
  1288. [(strict_fpround node:$src),
  1289. (fpround node:$src)]>;
  1290. def any_fpextend : PatFrags<(ops node:$src),
  1291. [(strict_fpextend node:$src),
  1292. (fpextend node:$src)]>;
  1293. def any_extloadf32 : PatFrags<(ops node:$ptr),
  1294. [(strict_extloadf32 node:$ptr),
  1295. (extloadf32 node:$ptr)]>;
  1296. def any_extloadf64 : PatFrags<(ops node:$ptr),
  1297. [(strict_extloadf64 node:$ptr),
  1298. (extloadf64 node:$ptr)]>;
  1299. def any_fp_to_sint : PatFrags<(ops node:$src),
  1300. [(strict_fp_to_sint node:$src),
  1301. (fp_to_sint node:$src)]>;
  1302. def any_fp_to_uint : PatFrags<(ops node:$src),
  1303. [(strict_fp_to_uint node:$src),
  1304. (fp_to_uint node:$src)]>;
  1305. def any_sint_to_fp : PatFrags<(ops node:$src),
  1306. [(strict_sint_to_fp node:$src),
  1307. (sint_to_fp node:$src)]>;
  1308. def any_uint_to_fp : PatFrags<(ops node:$src),
  1309. [(strict_uint_to_fp node:$src),
  1310. (uint_to_fp node:$src)]>;
  1311. def any_fsetcc : PatFrags<(ops node:$lhs, node:$rhs, node:$pred),
  1312. [(strict_fsetcc node:$lhs, node:$rhs, node:$pred),
  1313. (setcc node:$lhs, node:$rhs, node:$pred)]>;
  1314. def any_fsetccs : PatFrags<(ops node:$lhs, node:$rhs, node:$pred),
  1315. [(strict_fsetccs node:$lhs, node:$rhs, node:$pred),
  1316. (setcc node:$lhs, node:$rhs, node:$pred)]>;
  1317. multiclass binary_atomic_op_ord<SDNode atomic_op> {
  1318. def NAME#_monotonic : PatFrag<(ops node:$ptr, node:$val),
  1319. (!cast<SDPatternOperator>(NAME) node:$ptr, node:$val)> {
  1320. let IsAtomic = true;
  1321. let IsAtomicOrderingMonotonic = true;
  1322. }
  1323. def NAME#_acquire : PatFrag<(ops node:$ptr, node:$val),
  1324. (!cast<SDPatternOperator>(NAME) node:$ptr, node:$val)> {
  1325. let IsAtomic = true;
  1326. let IsAtomicOrderingAcquire = true;
  1327. }
  1328. def NAME#_release : PatFrag<(ops node:$ptr, node:$val),
  1329. (!cast<SDPatternOperator>(NAME) node:$ptr, node:$val)> {
  1330. let IsAtomic = true;
  1331. let IsAtomicOrderingRelease = true;
  1332. }
  1333. def NAME#_acq_rel : PatFrag<(ops node:$ptr, node:$val),
  1334. (!cast<SDPatternOperator>(NAME) node:$ptr, node:$val)> {
  1335. let IsAtomic = true;
  1336. let IsAtomicOrderingAcquireRelease = true;
  1337. }
  1338. def NAME#_seq_cst : PatFrag<(ops node:$ptr, node:$val),
  1339. (!cast<SDPatternOperator>(NAME) node:$ptr, node:$val)> {
  1340. let IsAtomic = true;
  1341. let IsAtomicOrderingSequentiallyConsistent = true;
  1342. }
  1343. }
  1344. multiclass ternary_atomic_op_ord<SDNode atomic_op> {
  1345. def NAME#_monotonic : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
  1346. (!cast<SDPatternOperator>(NAME) node:$ptr, node:$cmp, node:$val)> {
  1347. let IsAtomic = true;
  1348. let IsAtomicOrderingMonotonic = true;
  1349. }
  1350. def NAME#_acquire : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
  1351. (!cast<SDPatternOperator>(NAME) node:$ptr, node:$cmp, node:$val)> {
  1352. let IsAtomic = true;
  1353. let IsAtomicOrderingAcquire = true;
  1354. }
  1355. def NAME#_release : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
  1356. (!cast<SDPatternOperator>(NAME) node:$ptr, node:$cmp, node:$val)> {
  1357. let IsAtomic = true;
  1358. let IsAtomicOrderingRelease = true;
  1359. }
  1360. def NAME#_acq_rel : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
  1361. (!cast<SDPatternOperator>(NAME) node:$ptr, node:$cmp, node:$val)> {
  1362. let IsAtomic = true;
  1363. let IsAtomicOrderingAcquireRelease = true;
  1364. }
  1365. def NAME#_seq_cst : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
  1366. (!cast<SDPatternOperator>(NAME) node:$ptr, node:$cmp, node:$val)> {
  1367. let IsAtomic = true;
  1368. let IsAtomicOrderingSequentiallyConsistent = true;
  1369. }
  1370. }
  1371. multiclass binary_atomic_op<SDNode atomic_op, bit IsInt = 1> {
  1372. def _8 : PatFrag<(ops node:$ptr, node:$val),
  1373. (atomic_op node:$ptr, node:$val)> {
  1374. let IsAtomic = true;
  1375. let MemoryVT = !if(IsInt, i8, ?);
  1376. }
  1377. def _16 : PatFrag<(ops node:$ptr, node:$val),
  1378. (atomic_op node:$ptr, node:$val)> {
  1379. let IsAtomic = true;
  1380. let MemoryVT = !if(IsInt, i16, f16);
  1381. }
  1382. def _32 : PatFrag<(ops node:$ptr, node:$val),
  1383. (atomic_op node:$ptr, node:$val)> {
  1384. let IsAtomic = true;
  1385. let MemoryVT = !if(IsInt, i32, f32);
  1386. }
  1387. def _64 : PatFrag<(ops node:$ptr, node:$val),
  1388. (atomic_op node:$ptr, node:$val)> {
  1389. let IsAtomic = true;
  1390. let MemoryVT = !if(IsInt, i64, f64);
  1391. }
  1392. defm NAME#_8 : binary_atomic_op_ord<atomic_op>;
  1393. defm NAME#_16 : binary_atomic_op_ord<atomic_op>;
  1394. defm NAME#_32 : binary_atomic_op_ord<atomic_op>;
  1395. defm NAME#_64 : binary_atomic_op_ord<atomic_op>;
  1396. }
  1397. multiclass ternary_atomic_op<SDNode atomic_op> {
  1398. def _8 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
  1399. (atomic_op node:$ptr, node:$cmp, node:$val)> {
  1400. let IsAtomic = true;
  1401. let MemoryVT = i8;
  1402. }
  1403. def _16 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
  1404. (atomic_op node:$ptr, node:$cmp, node:$val)> {
  1405. let IsAtomic = true;
  1406. let MemoryVT = i16;
  1407. }
  1408. def _32 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
  1409. (atomic_op node:$ptr, node:$cmp, node:$val)> {
  1410. let IsAtomic = true;
  1411. let MemoryVT = i32;
  1412. }
  1413. def _64 : PatFrag<(ops node:$ptr, node:$cmp, node:$val),
  1414. (atomic_op node:$ptr, node:$cmp, node:$val)> {
  1415. let IsAtomic = true;
  1416. let MemoryVT = i64;
  1417. }
  1418. defm NAME#_8 : ternary_atomic_op_ord<atomic_op>;
  1419. defm NAME#_16 : ternary_atomic_op_ord<atomic_op>;
  1420. defm NAME#_32 : ternary_atomic_op_ord<atomic_op>;
  1421. defm NAME#_64 : ternary_atomic_op_ord<atomic_op>;
  1422. }
  1423. defm atomic_load_add : binary_atomic_op<atomic_load_add>;
  1424. defm atomic_swap : binary_atomic_op<atomic_swap>;
  1425. defm atomic_load_sub : binary_atomic_op<atomic_load_sub>;
  1426. defm atomic_load_and : binary_atomic_op<atomic_load_and>;
  1427. defm atomic_load_clr : binary_atomic_op<atomic_load_clr>;
  1428. defm atomic_load_or : binary_atomic_op<atomic_load_or>;
  1429. defm atomic_load_xor : binary_atomic_op<atomic_load_xor>;
  1430. defm atomic_load_nand : binary_atomic_op<atomic_load_nand>;
  1431. defm atomic_load_min : binary_atomic_op<atomic_load_min>;
  1432. defm atomic_load_max : binary_atomic_op<atomic_load_max>;
  1433. defm atomic_load_umin : binary_atomic_op<atomic_load_umin>;
  1434. defm atomic_load_umax : binary_atomic_op<atomic_load_umax>;
  1435. defm atomic_store : binary_atomic_op<atomic_store>;
  1436. defm atomic_cmp_swap : ternary_atomic_op<atomic_cmp_swap>;
  1437. def atomic_load_8 :
  1438. PatFrag<(ops node:$ptr),
  1439. (atomic_load node:$ptr)> {
  1440. let IsAtomic = true;
  1441. let MemoryVT = i8;
  1442. }
  1443. def atomic_load_16 :
  1444. PatFrag<(ops node:$ptr),
  1445. (atomic_load node:$ptr)> {
  1446. let IsAtomic = true;
  1447. let MemoryVT = i16;
  1448. }
  1449. def atomic_load_32 :
  1450. PatFrag<(ops node:$ptr),
  1451. (atomic_load node:$ptr)> {
  1452. let IsAtomic = true;
  1453. let MemoryVT = i32;
  1454. }
  1455. def atomic_load_64 :
  1456. PatFrag<(ops node:$ptr),
  1457. (atomic_load node:$ptr)> {
  1458. let IsAtomic = true;
  1459. let MemoryVT = i64;
  1460. }
  1461. //===----------------------------------------------------------------------===//
  1462. // Selection DAG Pattern Support.
  1463. //
  1464. // Patterns are what are actually matched against by the target-flavored
  1465. // instruction selection DAG. Instructions defined by the target implicitly
  1466. // define patterns in most cases, but patterns can also be explicitly added when
  1467. // an operation is defined by a sequence of instructions (e.g. loading a large
  1468. // immediate value on RISC targets that do not support immediates as large as
  1469. // their GPRs).
  1470. //
  1471. class Pattern<dag patternToMatch, list<dag> resultInstrs> {
  1472. dag PatternToMatch = patternToMatch;
  1473. list<dag> ResultInstrs = resultInstrs;
  1474. list<Predicate> Predicates = []; // See class Instruction in Target.td.
  1475. int AddedComplexity = 0; // See class Instruction in Target.td.
  1476. }
  1477. // Pat - A simple (but common) form of a pattern, which produces a simple result
  1478. // not needing a full list.
  1479. class Pat<dag pattern, dag result> : Pattern<pattern, [result]>;
  1480. //===----------------------------------------------------------------------===//
  1481. // Complex pattern definitions.
  1482. //
  1483. // Complex patterns, e.g. X86 addressing mode, requires pattern matching code
  1484. // in C++. NumOperands is the number of operands returned by the select function;
  1485. // SelectFunc is the name of the function used to pattern match the max. pattern;
  1486. // RootNodes are the list of possible root nodes of the sub-dags to match.
  1487. // e.g. X86 addressing mode - def addr : ComplexPattern<4, "SelectAddr", [add]>;
  1488. //
  1489. class ComplexPattern<ValueType ty, int numops, string fn,
  1490. list<SDNode> roots = [], list<SDNodeProperty> props = [],
  1491. int complexity = -1> {
  1492. ValueType Ty = ty;
  1493. int NumOperands = numops;
  1494. string SelectFunc = fn;
  1495. list<SDNode> RootNodes = roots;
  1496. list<SDNodeProperty> Properties = props;
  1497. int Complexity = complexity;
  1498. }