TargetSelectionDAG.td 70 KB

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