TargetSelectionDAG.td 70 KB

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