TargetSelectionDAG.td 79 KB

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