ISDOpcodes.h 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- llvm/CodeGen/ISDOpcodes.h - CodeGen opcodes -------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file declares codegen opcodes and related utilities.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_CODEGEN_ISDOPCODES_H
  18. #define LLVM_CODEGEN_ISDOPCODES_H
  19. #include "llvm/CodeGen/ValueTypes.h"
  20. namespace llvm {
  21. /// ISD namespace - This namespace contains an enum which represents all of the
  22. /// SelectionDAG node types and value types.
  23. ///
  24. namespace ISD {
  25. //===--------------------------------------------------------------------===//
  26. /// ISD::NodeType enum - This enum defines the target-independent operators
  27. /// for a SelectionDAG.
  28. ///
  29. /// Targets may also define target-dependent operator codes for SDNodes. For
  30. /// example, on x86, these are the enum values in the X86ISD namespace.
  31. /// Targets should aim to use target-independent operators to model their
  32. /// instruction sets as much as possible, and only use target-dependent
  33. /// operators when they have special requirements.
  34. ///
  35. /// Finally, during and after selection proper, SNodes may use special
  36. /// operator codes that correspond directly with MachineInstr opcodes. These
  37. /// are used to represent selected instructions. See the isMachineOpcode()
  38. /// and getMachineOpcode() member functions of SDNode.
  39. ///
  40. enum NodeType {
  41. /// DELETED_NODE - This is an illegal value that is used to catch
  42. /// errors. This opcode is not a legal opcode for any node.
  43. DELETED_NODE,
  44. /// EntryToken - This is the marker used to indicate the start of a region.
  45. EntryToken,
  46. /// TokenFactor - This node takes multiple tokens as input and produces a
  47. /// single token result. This is used to represent the fact that the operand
  48. /// operators are independent of each other.
  49. TokenFactor,
  50. /// AssertSext, AssertZext - These nodes record if a register contains a
  51. /// value that has already been zero or sign extended from a narrower type.
  52. /// These nodes take two operands. The first is the node that has already
  53. /// been extended, and the second is a value type node indicating the width
  54. /// of the extension.
  55. /// NOTE: In case of the source value (or any vector element value) is
  56. /// poisoned the assertion will not be true for that value.
  57. AssertSext,
  58. AssertZext,
  59. /// AssertAlign - These nodes record if a register contains a value that
  60. /// has a known alignment and the trailing bits are known to be zero.
  61. /// NOTE: In case of the source value (or any vector element value) is
  62. /// poisoned the assertion will not be true for that value.
  63. AssertAlign,
  64. /// Various leaf nodes.
  65. BasicBlock,
  66. VALUETYPE,
  67. CONDCODE,
  68. Register,
  69. RegisterMask,
  70. Constant,
  71. ConstantFP,
  72. GlobalAddress,
  73. GlobalTLSAddress,
  74. FrameIndex,
  75. JumpTable,
  76. ConstantPool,
  77. ExternalSymbol,
  78. BlockAddress,
  79. /// The address of the GOT
  80. GLOBAL_OFFSET_TABLE,
  81. /// FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and
  82. /// llvm.returnaddress on the DAG. These nodes take one operand, the index
  83. /// of the frame or return address to return. An index of zero corresponds
  84. /// to the current function's frame or return address, an index of one to
  85. /// the parent's frame or return address, and so on.
  86. FRAMEADDR,
  87. RETURNADDR,
  88. /// ADDROFRETURNADDR - Represents the llvm.addressofreturnaddress intrinsic.
  89. /// This node takes no operand, returns a target-specific pointer to the
  90. /// place in the stack frame where the return address of the current
  91. /// function is stored.
  92. ADDROFRETURNADDR,
  93. /// SPONENTRY - Represents the llvm.sponentry intrinsic. Takes no argument
  94. /// and returns the stack pointer value at the entry of the current
  95. /// function calling this intrinsic.
  96. SPONENTRY,
  97. /// LOCAL_RECOVER - Represents the llvm.localrecover intrinsic.
  98. /// Materializes the offset from the local object pointer of another
  99. /// function to a particular local object passed to llvm.localescape. The
  100. /// operand is the MCSymbol label used to represent this offset, since
  101. /// typically the offset is not known until after code generation of the
  102. /// parent.
  103. LOCAL_RECOVER,
  104. /// READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on
  105. /// the DAG, which implements the named register global variables extension.
  106. READ_REGISTER,
  107. WRITE_REGISTER,
  108. /// FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to
  109. /// first (possible) on-stack argument. This is needed for correct stack
  110. /// adjustment during unwind.
  111. FRAME_TO_ARGS_OFFSET,
  112. /// EH_DWARF_CFA - This node represents the pointer to the DWARF Canonical
  113. /// Frame Address (CFA), generally the value of the stack pointer at the
  114. /// call site in the previous frame.
  115. EH_DWARF_CFA,
  116. /// OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents
  117. /// 'eh_return' gcc dwarf builtin, which is used to return from
  118. /// exception. The general meaning is: adjust stack by OFFSET and pass
  119. /// execution to HANDLER. Many platform-related details also :)
  120. EH_RETURN,
  121. /// RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer)
  122. /// This corresponds to the eh.sjlj.setjmp intrinsic.
  123. /// It takes an input chain and a pointer to the jump buffer as inputs
  124. /// and returns an outchain.
  125. EH_SJLJ_SETJMP,
  126. /// OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer)
  127. /// This corresponds to the eh.sjlj.longjmp intrinsic.
  128. /// It takes an input chain and a pointer to the jump buffer as inputs
  129. /// and returns an outchain.
  130. EH_SJLJ_LONGJMP,
  131. /// OUTCHAIN = EH_SJLJ_SETUP_DISPATCH(INCHAIN)
  132. /// The target initializes the dispatch table here.
  133. EH_SJLJ_SETUP_DISPATCH,
  134. /// TargetConstant* - Like Constant*, but the DAG does not do any folding,
  135. /// simplification, or lowering of the constant. They are used for constants
  136. /// which are known to fit in the immediate fields of their users, or for
  137. /// carrying magic numbers which are not values which need to be
  138. /// materialized in registers.
  139. TargetConstant,
  140. TargetConstantFP,
  141. /// TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
  142. /// anything else with this node, and this is valid in the target-specific
  143. /// dag, turning into a GlobalAddress operand.
  144. TargetGlobalAddress,
  145. TargetGlobalTLSAddress,
  146. TargetFrameIndex,
  147. TargetJumpTable,
  148. TargetConstantPool,
  149. TargetExternalSymbol,
  150. TargetBlockAddress,
  151. MCSymbol,
  152. /// TargetIndex - Like a constant pool entry, but with completely
  153. /// target-dependent semantics. Holds target flags, a 32-bit index, and a
  154. /// 64-bit index. Targets can use this however they like.
  155. TargetIndex,
  156. /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
  157. /// This node represents a target intrinsic function with no side effects.
  158. /// The first operand is the ID number of the intrinsic from the
  159. /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The
  160. /// node returns the result of the intrinsic.
  161. INTRINSIC_WO_CHAIN,
  162. /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
  163. /// This node represents a target intrinsic function with side effects that
  164. /// returns a result. The first operand is a chain pointer. The second is
  165. /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The
  166. /// operands to the intrinsic follow. The node has two results, the result
  167. /// of the intrinsic and an output chain.
  168. INTRINSIC_W_CHAIN,
  169. /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
  170. /// This node represents a target intrinsic function with side effects that
  171. /// does not return a result. The first operand is a chain pointer. The
  172. /// second is the ID number of the intrinsic from the llvm::Intrinsic
  173. /// namespace. The operands to the intrinsic follow.
  174. INTRINSIC_VOID,
  175. /// CopyToReg - This node has three operands: a chain, a register number to
  176. /// set to this value, and a value.
  177. CopyToReg,
  178. /// CopyFromReg - This node indicates that the input value is a virtual or
  179. /// physical register that is defined outside of the scope of this
  180. /// SelectionDAG. The register is available from the RegisterSDNode object.
  181. CopyFromReg,
  182. /// UNDEF - An undefined node.
  183. UNDEF,
  184. // FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or
  185. // is evaluated to UNDEF), or returns VAL otherwise. Note that each
  186. // read of UNDEF can yield different value, but FREEZE(UNDEF) cannot.
  187. FREEZE,
  188. /// EXTRACT_ELEMENT - This is used to get the lower or upper (determined by
  189. /// a Constant, which is required to be operand #1) half of the integer or
  190. /// float value specified as operand #0. This is only for use before
  191. /// legalization, for values that will be broken into multiple registers.
  192. EXTRACT_ELEMENT,
  193. /// BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
  194. /// Given two values of the same integer value type, this produces a value
  195. /// twice as big. Like EXTRACT_ELEMENT, this can only be used before
  196. /// legalization. The lower part of the composite value should be in
  197. /// element 0 and the upper part should be in element 1.
  198. BUILD_PAIR,
  199. /// MERGE_VALUES - This node takes multiple discrete operands and returns
  200. /// them all as its individual results. This nodes has exactly the same
  201. /// number of inputs and outputs. This node is useful for some pieces of the
  202. /// code generator that want to think about a single node with multiple
  203. /// results, not multiple nodes.
  204. MERGE_VALUES,
  205. /// Simple integer binary arithmetic operators.
  206. ADD,
  207. SUB,
  208. MUL,
  209. SDIV,
  210. UDIV,
  211. SREM,
  212. UREM,
  213. /// SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing
  214. /// a signed/unsigned value of type i[2*N], and return the full value as
  215. /// two results, each of type iN.
  216. SMUL_LOHI,
  217. UMUL_LOHI,
  218. /// SDIVREM/UDIVREM - Divide two integers and produce both a quotient and
  219. /// remainder result.
  220. SDIVREM,
  221. UDIVREM,
  222. /// CARRY_FALSE - This node is used when folding other nodes,
  223. /// like ADDC/SUBC, which indicate the carry result is always false.
  224. CARRY_FALSE,
  225. /// Carry-setting nodes for multiple precision addition and subtraction.
  226. /// These nodes take two operands of the same value type, and produce two
  227. /// results. The first result is the normal add or sub result, the second
  228. /// result is the carry flag result.
  229. /// FIXME: These nodes are deprecated in favor of ADDCARRY and SUBCARRY.
  230. /// They are kept around for now to provide a smooth transition path
  231. /// toward the use of ADDCARRY/SUBCARRY and will eventually be removed.
  232. ADDC,
  233. SUBC,
  234. /// Carry-using nodes for multiple precision addition and subtraction. These
  235. /// nodes take three operands: The first two are the normal lhs and rhs to
  236. /// the add or sub, and the third is the input carry flag. These nodes
  237. /// produce two results; the normal result of the add or sub, and the output
  238. /// carry flag. These nodes both read and write a carry flag to allow them
  239. /// to them to be chained together for add and sub of arbitrarily large
  240. /// values.
  241. ADDE,
  242. SUBE,
  243. /// Carry-using nodes for multiple precision addition and subtraction.
  244. /// These nodes take three operands: The first two are the normal lhs and
  245. /// rhs to the add or sub, and the third is a boolean value that is 1 if and
  246. /// only if there is an incoming carry/borrow. These nodes produce two
  247. /// results: the normal result of the add or sub, and a boolean value that is
  248. /// 1 if and only if there is an outgoing carry/borrow.
  249. ///
  250. /// Care must be taken if these opcodes are lowered to hardware instructions
  251. /// that use the inverse logic -- 0 if and only if there is an
  252. /// incoming/outgoing carry/borrow. In such cases, you must preserve the
  253. /// semantics of these opcodes by inverting the incoming carry/borrow, feeding
  254. /// it to the add/sub hardware instruction, and then inverting the outgoing
  255. /// carry/borrow.
  256. ///
  257. /// The use of these opcodes is preferable to adde/sube if the target supports
  258. /// it, as the carry is a regular value rather than a glue, which allows
  259. /// further optimisation.
  260. ///
  261. /// These opcodes are different from [US]{ADD,SUB}O in that ADDCARRY/SUBCARRY
  262. /// consume and produce a carry/borrow, whereas [US]{ADD,SUB}O produce an
  263. /// overflow.
  264. ADDCARRY,
  265. SUBCARRY,
  266. /// Carry-using overflow-aware nodes for multiple precision addition and
  267. /// subtraction. These nodes take three operands: The first two are normal lhs
  268. /// and rhs to the add or sub, and the third is a boolean indicating if there
  269. /// is an incoming carry. They produce two results: the normal result of the
  270. /// add or sub, and a boolean that indicates if an overflow occurred (*not*
  271. /// flag, because it may be a store to memory, etc.). If the type of the
  272. /// boolean is not i1 then the high bits conform to getBooleanContents.
  273. SADDO_CARRY,
  274. SSUBO_CARRY,
  275. /// RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
  276. /// These nodes take two operands: the normal LHS and RHS to the add. They
  277. /// produce two results: the normal result of the add, and a boolean that
  278. /// indicates if an overflow occurred (*not* a flag, because it may be store
  279. /// to memory, etc.). If the type of the boolean is not i1 then the high
  280. /// bits conform to getBooleanContents.
  281. /// These nodes are generated from llvm.[su]add.with.overflow intrinsics.
  282. SADDO,
  283. UADDO,
  284. /// Same for subtraction.
  285. SSUBO,
  286. USUBO,
  287. /// Same for multiplication.
  288. SMULO,
  289. UMULO,
  290. /// RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2
  291. /// integers with the same bit width (W). If the true value of LHS + RHS
  292. /// exceeds the largest value that can be represented by W bits, the
  293. /// resulting value is this maximum value. Otherwise, if this value is less
  294. /// than the smallest value that can be represented by W bits, the
  295. /// resulting value is this minimum value.
  296. SADDSAT,
  297. UADDSAT,
  298. /// RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2
  299. /// integers with the same bit width (W). If the true value of LHS - RHS
  300. /// exceeds the largest value that can be represented by W bits, the
  301. /// resulting value is this maximum value. Otherwise, if this value is less
  302. /// than the smallest value that can be represented by W bits, the
  303. /// resulting value is this minimum value.
  304. SSUBSAT,
  305. USUBSAT,
  306. /// RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift. The first
  307. /// operand is the value to be shifted, and the second argument is the amount
  308. /// to shift by. Both must be integers of the same bit width (W). If the true
  309. /// value of LHS << RHS exceeds the largest value that can be represented by
  310. /// W bits, the resulting value is this maximum value, Otherwise, if this
  311. /// value is less than the smallest value that can be represented by W bits,
  312. /// the resulting value is this minimum value.
  313. SSHLSAT,
  314. USHLSAT,
  315. /// RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication
  316. /// on 2 integers with the same width and scale. SCALE represents the scale
  317. /// of both operands as fixed point numbers. This SCALE parameter must be a
  318. /// constant integer. A scale of zero is effectively performing
  319. /// multiplication on 2 integers.
  320. SMULFIX,
  321. UMULFIX,
  322. /// Same as the corresponding unsaturated fixed point instructions, but the
  323. /// result is clamped between the min and max values representable by the
  324. /// bits of the first 2 operands.
  325. SMULFIXSAT,
  326. UMULFIXSAT,
  327. /// RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on
  328. /// 2 integers with the same width and scale. SCALE represents the scale
  329. /// of both operands as fixed point numbers. This SCALE parameter must be a
  330. /// constant integer.
  331. SDIVFIX,
  332. UDIVFIX,
  333. /// Same as the corresponding unsaturated fixed point instructions, but the
  334. /// result is clamped between the min and max values representable by the
  335. /// bits of the first 2 operands.
  336. SDIVFIXSAT,
  337. UDIVFIXSAT,
  338. /// Simple binary floating point operators.
  339. FADD,
  340. FSUB,
  341. FMUL,
  342. FDIV,
  343. FREM,
  344. /// Constrained versions of the binary floating point operators.
  345. /// These will be lowered to the simple operators before final selection.
  346. /// They are used to limit optimizations while the DAG is being
  347. /// optimized.
  348. STRICT_FADD,
  349. STRICT_FSUB,
  350. STRICT_FMUL,
  351. STRICT_FDIV,
  352. STRICT_FREM,
  353. STRICT_FMA,
  354. /// Constrained versions of libm-equivalent floating point intrinsics.
  355. /// These will be lowered to the equivalent non-constrained pseudo-op
  356. /// (or expanded to the equivalent library call) before final selection.
  357. /// They are used to limit optimizations while the DAG is being optimized.
  358. STRICT_FSQRT,
  359. STRICT_FPOW,
  360. STRICT_FPOWI,
  361. STRICT_FSIN,
  362. STRICT_FCOS,
  363. STRICT_FEXP,
  364. STRICT_FEXP2,
  365. STRICT_FLOG,
  366. STRICT_FLOG10,
  367. STRICT_FLOG2,
  368. STRICT_FRINT,
  369. STRICT_FNEARBYINT,
  370. STRICT_FMAXNUM,
  371. STRICT_FMINNUM,
  372. STRICT_FCEIL,
  373. STRICT_FFLOOR,
  374. STRICT_FROUND,
  375. STRICT_FROUNDEVEN,
  376. STRICT_FTRUNC,
  377. STRICT_LROUND,
  378. STRICT_LLROUND,
  379. STRICT_LRINT,
  380. STRICT_LLRINT,
  381. STRICT_FMAXIMUM,
  382. STRICT_FMINIMUM,
  383. /// STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or
  384. /// unsigned integer. These have the same semantics as fptosi and fptoui
  385. /// in IR.
  386. /// They are used to limit optimizations while the DAG is being optimized.
  387. STRICT_FP_TO_SINT,
  388. STRICT_FP_TO_UINT,
  389. /// STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to
  390. /// a floating point value. These have the same semantics as sitofp and
  391. /// uitofp in IR.
  392. /// They are used to limit optimizations while the DAG is being optimized.
  393. STRICT_SINT_TO_FP,
  394. STRICT_UINT_TO_FP,
  395. /// X = STRICT_FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating
  396. /// point type down to the precision of the destination VT. TRUNC is a
  397. /// flag, which is always an integer that is zero or one. If TRUNC is 0,
  398. /// this is a normal rounding, if it is 1, this FP_ROUND is known to not
  399. /// change the value of Y.
  400. ///
  401. /// The TRUNC = 1 case is used in cases where we know that the value will
  402. /// not be modified by the node, because Y is not using any of the extra
  403. /// precision of source type. This allows certain transformations like
  404. /// STRICT_FP_EXTEND(STRICT_FP_ROUND(X,1)) -> X which are not safe for
  405. /// STRICT_FP_EXTEND(STRICT_FP_ROUND(X,0)) because the extra bits aren't
  406. /// removed.
  407. /// It is used to limit optimizations while the DAG is being optimized.
  408. STRICT_FP_ROUND,
  409. /// X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP
  410. /// type.
  411. /// It is used to limit optimizations while the DAG is being optimized.
  412. STRICT_FP_EXTEND,
  413. /// STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used
  414. /// for floating-point operands only. STRICT_FSETCC performs a quiet
  415. /// comparison operation, while STRICT_FSETCCS performs a signaling
  416. /// comparison operation.
  417. STRICT_FSETCC,
  418. STRICT_FSETCCS,
  419. // FPTRUNC_ROUND - This corresponds to the fptrunc_round intrinsic.
  420. FPTRUNC_ROUND,
  421. /// FMA - Perform a * b + c with no intermediate rounding step.
  422. FMA,
  423. /// FMAD - Perform a * b + c, while getting the same result as the
  424. /// separately rounded operations.
  425. FMAD,
  426. /// FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This
  427. /// DAG node does not require that X and Y have the same type, just that
  428. /// they are both floating point. X and the result must have the same type.
  429. /// FCOPYSIGN(f32, f64) is allowed.
  430. FCOPYSIGN,
  431. /// INT = FGETSIGN(FP) - Return the sign bit of the specified floating point
  432. /// value as an integer 0/1 value.
  433. FGETSIGN,
  434. /// Returns platform specific canonical encoding of a floating point number.
  435. FCANONICALIZE,
  436. /// Performs a check of floating point class property, defined by IEEE-754.
  437. /// The first operand is the floating point value to check. The second operand
  438. /// specifies the checked property and is a TargetConstant which specifies
  439. /// test in the same way as intrinsic 'is_fpclass'.
  440. /// Returns boolean value.
  441. IS_FPCLASS,
  442. /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector
  443. /// with the specified, possibly variable, elements. The types of the
  444. /// operands must match the vector element type, except that integer types
  445. /// are allowed to be larger than the element type, in which case the
  446. /// operands are implicitly truncated. The types of the operands must all
  447. /// be the same.
  448. BUILD_VECTOR,
  449. /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
  450. /// at IDX replaced with VAL. If the type of VAL is larger than the vector
  451. /// element type then VAL is truncated before replacement.
  452. ///
  453. /// If VECTOR is a scalable vector, then IDX may be larger than the minimum
  454. /// vector width. IDX is not first scaled by the runtime scaling factor of
  455. /// VECTOR.
  456. INSERT_VECTOR_ELT,
  457. /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
  458. /// identified by the (potentially variable) element number IDX. If the return
  459. /// type is an integer type larger than the element type of the vector, the
  460. /// result is extended to the width of the return type. In that case, the high
  461. /// bits are undefined.
  462. ///
  463. /// If VECTOR is a scalable vector, then IDX may be larger than the minimum
  464. /// vector width. IDX is not first scaled by the runtime scaling factor of
  465. /// VECTOR.
  466. EXTRACT_VECTOR_ELT,
  467. /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
  468. /// vector type with the same length and element type, this produces a
  469. /// concatenated vector result value, with length equal to the sum of the
  470. /// lengths of the input vectors. If VECTOR0 is a fixed-width vector, then
  471. /// VECTOR1..VECTORN must all be fixed-width vectors. Similarly, if VECTOR0
  472. /// is a scalable vector, then VECTOR1..VECTORN must all be scalable vectors.
  473. CONCAT_VECTORS,
  474. /// INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2
  475. /// inserted into VECTOR1. IDX represents the starting element number at which
  476. /// VECTOR2 will be inserted. IDX must be a constant multiple of T's known
  477. /// minimum vector length. Let the type of VECTOR2 be T, then if T is a
  478. /// scalable vector, IDX is first scaled by the runtime scaling factor of T.
  479. /// The elements of VECTOR1 starting at IDX are overwritten with VECTOR2.
  480. /// Elements IDX through (IDX + num_elements(T) - 1) must be valid VECTOR1
  481. /// indices. If this condition cannot be determined statically but is false at
  482. /// runtime, then the result vector is undefined. The IDX parameter must be a
  483. /// vector index constant type, which for most targets will be an integer
  484. /// pointer type.
  485. ///
  486. /// This operation supports inserting a fixed-width vector into a scalable
  487. /// vector, but not the other way around.
  488. INSERT_SUBVECTOR,
  489. /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
  490. /// Let the result type be T, then IDX represents the starting element number
  491. /// from which a subvector of type T is extracted. IDX must be a constant
  492. /// multiple of T's known minimum vector length. If T is a scalable vector,
  493. /// IDX is first scaled by the runtime scaling factor of T. Elements IDX
  494. /// through (IDX + num_elements(T) - 1) must be valid VECTOR indices. If this
  495. /// condition cannot be determined statically but is false at runtime, then
  496. /// the result vector is undefined. The IDX parameter must be a vector index
  497. /// constant type, which for most targets will be an integer pointer type.
  498. ///
  499. /// This operation supports extracting a fixed-width vector from a scalable
  500. /// vector, but not the other way around.
  501. EXTRACT_SUBVECTOR,
  502. /// VECTOR_REVERSE(VECTOR) - Returns a vector, of the same type as VECTOR,
  503. /// whose elements are shuffled using the following algorithm:
  504. /// RESULT[i] = VECTOR[VECTOR.ElementCount - 1 - i]
  505. VECTOR_REVERSE,
  506. /// VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as
  507. /// VEC1/VEC2. A VECTOR_SHUFFLE node also contains an array of constant int
  508. /// values that indicate which value (or undef) each result element will
  509. /// get. These constant ints are accessible through the
  510. /// ShuffleVectorSDNode class. This is quite similar to the Altivec
  511. /// 'vperm' instruction, except that the indices must be constants and are
  512. /// in terms of the element size of VEC1/VEC2, not in terms of bytes.
  513. VECTOR_SHUFFLE,
  514. /// VECTOR_SPLICE(VEC1, VEC2, IMM) - Returns a subvector of the same type as
  515. /// VEC1/VEC2 from CONCAT_VECTORS(VEC1, VEC2), based on the IMM in two ways.
  516. /// Let the result type be T, if IMM is positive it represents the starting
  517. /// element number (an index) from which a subvector of type T is extracted
  518. /// from CONCAT_VECTORS(VEC1, VEC2). If IMM is negative it represents a count
  519. /// specifying the number of trailing elements to extract from VEC1, where the
  520. /// elements of T are selected using the following algorithm:
  521. /// RESULT[i] = CONCAT_VECTORS(VEC1,VEC2)[VEC1.ElementCount - ABS(IMM) + i]
  522. /// If IMM is not in the range [-VL, VL-1] the result vector is undefined. IMM
  523. /// is a constant integer.
  524. VECTOR_SPLICE,
  525. /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
  526. /// scalar value into element 0 of the resultant vector type. The top
  527. /// elements 1 to N-1 of the N-element vector are undefined. The type
  528. /// of the operand must match the vector element type, except when they
  529. /// are integer types. In this case the operand is allowed to be wider
  530. /// than the vector element type, and is implicitly truncated to it.
  531. SCALAR_TO_VECTOR,
  532. /// SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL
  533. /// duplicated in all lanes. The type of the operand must match the vector
  534. /// element type, except when they are integer types. In this case the
  535. /// operand is allowed to be wider than the vector element type, and is
  536. /// implicitly truncated to it.
  537. SPLAT_VECTOR,
  538. /// SPLAT_VECTOR_PARTS(SCALAR1, SCALAR2, ...) - Returns a vector with the
  539. /// scalar values joined together and then duplicated in all lanes. This
  540. /// represents a SPLAT_VECTOR that has had its scalar operand expanded. This
  541. /// allows representing a 64-bit splat on a target with 32-bit integers. The
  542. /// total width of the scalars must cover the element width. SCALAR1 contains
  543. /// the least significant bits of the value regardless of endianness and all
  544. /// scalars should have the same type.
  545. SPLAT_VECTOR_PARTS,
  546. /// STEP_VECTOR(IMM) - Returns a scalable vector whose lanes are comprised
  547. /// of a linear sequence of unsigned values starting from 0 with a step of
  548. /// IMM, where IMM must be a TargetConstant with type equal to the vector
  549. /// element type. The arithmetic is performed modulo the bitwidth of the
  550. /// element.
  551. ///
  552. /// The operation does not support returning fixed-width vectors or
  553. /// non-constant operands.
  554. STEP_VECTOR,
  555. /// MULHU/MULHS - Multiply high - Multiply two integers of type iN,
  556. /// producing an unsigned/signed value of type i[2*N], then return the top
  557. /// part.
  558. MULHU,
  559. MULHS,
  560. /// AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of
  561. /// type i[N+1], halving the result by shifting it one bit right.
  562. /// shr(add(ext(X), ext(Y)), 1)
  563. AVGFLOORS,
  564. AVGFLOORU,
  565. /// AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an
  566. /// integer of type i[N+2], add 1 and halve the result by shifting it one bit
  567. /// right. shr(add(ext(X), ext(Y), 1), 1)
  568. AVGCEILS,
  569. AVGCEILU,
  570. // ABDS/ABDU - Absolute difference - Return the absolute difference between
  571. // two numbers interpreted as signed/unsigned.
  572. // i.e trunc(abs(sext(Op0) - sext(Op1))) becomes abds(Op0, Op1)
  573. // or trunc(abs(zext(Op0) - zext(Op1))) becomes abdu(Op0, Op1)
  574. ABDS,
  575. ABDU,
  576. /// [US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned
  577. /// integers.
  578. SMIN,
  579. SMAX,
  580. UMIN,
  581. UMAX,
  582. /// Bitwise operators - logical and, logical or, logical xor.
  583. AND,
  584. OR,
  585. XOR,
  586. /// ABS - Determine the unsigned absolute value of a signed integer value of
  587. /// the same bitwidth.
  588. /// Note: A value of INT_MIN will return INT_MIN, no saturation or overflow
  589. /// is performed.
  590. ABS,
  591. /// Shift and rotation operations. After legalization, the type of the
  592. /// shift amount is known to be TLI.getShiftAmountTy(). Before legalization
  593. /// the shift amount can be any type, but care must be taken to ensure it is
  594. /// large enough. TLI.getShiftAmountTy() is i8 on some targets, but before
  595. /// legalization, types like i1024 can occur and i8 doesn't have enough bits
  596. /// to represent the shift amount.
  597. /// When the 1st operand is a vector, the shift amount must be in the same
  598. /// type. (TLI.getShiftAmountTy() will return the same type when the input
  599. /// type is a vector.)
  600. /// For rotates and funnel shifts, the shift amount is treated as an unsigned
  601. /// amount modulo the element size of the first operand.
  602. ///
  603. /// Funnel 'double' shifts take 3 operands, 2 inputs and the shift amount.
  604. /// fshl(X,Y,Z): (X << (Z % BW)) | (Y >> (BW - (Z % BW)))
  605. /// fshr(X,Y,Z): (X << (BW - (Z % BW))) | (Y >> (Z % BW))
  606. SHL,
  607. SRA,
  608. SRL,
  609. ROTL,
  610. ROTR,
  611. FSHL,
  612. FSHR,
  613. /// Byte Swap and Counting operators.
  614. BSWAP,
  615. CTTZ,
  616. CTLZ,
  617. CTPOP,
  618. BITREVERSE,
  619. PARITY,
  620. /// Bit counting operators with an undefined result for zero inputs.
  621. CTTZ_ZERO_UNDEF,
  622. CTLZ_ZERO_UNDEF,
  623. /// Select(COND, TRUEVAL, FALSEVAL). If the type of the boolean COND is not
  624. /// i1 then the high bits must conform to getBooleanContents.
  625. SELECT,
  626. /// Select with a vector condition (op #0) and two vector operands (ops #1
  627. /// and #2), returning a vector result. All vectors have the same length.
  628. /// Much like the scalar select and setcc, each bit in the condition selects
  629. /// whether the corresponding result element is taken from op #1 or op #2.
  630. /// At first, the VSELECT condition is of vXi1 type. Later, targets may
  631. /// change the condition type in order to match the VSELECT node using a
  632. /// pattern. The condition follows the BooleanContent format of the target.
  633. VSELECT,
  634. /// Select with condition operator - This selects between a true value and
  635. /// a false value (ops #2 and #3) based on the boolean result of comparing
  636. /// the lhs and rhs (ops #0 and #1) of a conditional expression with the
  637. /// condition code in op #4, a CondCodeSDNode.
  638. SELECT_CC,
  639. /// SetCC operator - This evaluates to a true value iff the condition is
  640. /// true. If the result value type is not i1 then the high bits conform
  641. /// to getBooleanContents. The operands to this are the left and right
  642. /// operands to compare (ops #0, and #1) and the condition code to compare
  643. /// them with (op #2) as a CondCodeSDNode. If the operands are vector types
  644. /// then the result type must also be a vector type.
  645. SETCC,
  646. /// Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but
  647. /// op #2 is a boolean indicating if there is an incoming carry. This
  648. /// operator checks the result of "LHS - RHS - Carry", and can be used to
  649. /// compare two wide integers:
  650. /// (setcccarry lhshi rhshi (subcarry lhslo rhslo) cc).
  651. /// Only valid for integers.
  652. SETCCCARRY,
  653. /// SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
  654. /// integer shift operations. The operation ordering is:
  655. /// [Lo,Hi] = op [LoLHS,HiLHS], Amt
  656. SHL_PARTS,
  657. SRA_PARTS,
  658. SRL_PARTS,
  659. /// Conversion operators. These are all single input single output
  660. /// operations. For all of these, the result type must be strictly
  661. /// wider or narrower (depending on the operation) than the source
  662. /// type.
  663. /// SIGN_EXTEND - Used for integer types, replicating the sign bit
  664. /// into new bits.
  665. SIGN_EXTEND,
  666. /// ZERO_EXTEND - Used for integer types, zeroing the new bits.
  667. ZERO_EXTEND,
  668. /// ANY_EXTEND - Used for integer types. The high bits are undefined.
  669. ANY_EXTEND,
  670. /// TRUNCATE - Completely drop the high bits.
  671. TRUNCATE,
  672. /// [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
  673. /// depends on the first letter) to floating point.
  674. SINT_TO_FP,
  675. UINT_TO_FP,
  676. /// SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
  677. /// sign extend a small value in a large integer register (e.g. sign
  678. /// extending the low 8 bits of a 32-bit register to fill the top 24 bits
  679. /// with the 7th bit). The size of the smaller type is indicated by the 1th
  680. /// operand, a ValueType node.
  681. SIGN_EXTEND_INREG,
  682. /// ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an
  683. /// in-register any-extension of the low lanes of an integer vector. The
  684. /// result type must have fewer elements than the operand type, and those
  685. /// elements must be larger integer types such that the total size of the
  686. /// operand type is less than or equal to the size of the result type. Each
  687. /// of the low operand elements is any-extended into the corresponding,
  688. /// wider result elements with the high bits becoming undef.
  689. /// NOTE: The type legalizer prefers to make the operand and result size
  690. /// the same to allow expansion to shuffle vector during op legalization.
  691. ANY_EXTEND_VECTOR_INREG,
  692. /// SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an
  693. /// in-register sign-extension of the low lanes of an integer vector. The
  694. /// result type must have fewer elements than the operand type, and those
  695. /// elements must be larger integer types such that the total size of the
  696. /// operand type is less than or equal to the size of the result type. Each
  697. /// of the low operand elements is sign-extended into the corresponding,
  698. /// wider result elements.
  699. /// NOTE: The type legalizer prefers to make the operand and result size
  700. /// the same to allow expansion to shuffle vector during op legalization.
  701. SIGN_EXTEND_VECTOR_INREG,
  702. /// ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an
  703. /// in-register zero-extension of the low lanes of an integer vector. The
  704. /// result type must have fewer elements than the operand type, and those
  705. /// elements must be larger integer types such that the total size of the
  706. /// operand type is less than or equal to the size of the result type. Each
  707. /// of the low operand elements is zero-extended into the corresponding,
  708. /// wider result elements.
  709. /// NOTE: The type legalizer prefers to make the operand and result size
  710. /// the same to allow expansion to shuffle vector during op legalization.
  711. ZERO_EXTEND_VECTOR_INREG,
  712. /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
  713. /// integer. These have the same semantics as fptosi and fptoui in IR. If
  714. /// the FP value cannot fit in the integer type, the results are undefined.
  715. FP_TO_SINT,
  716. FP_TO_UINT,
  717. /// FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a
  718. /// signed or unsigned scalar integer type given in operand 1 with the
  719. /// following semantics:
  720. ///
  721. /// * If the value is NaN, zero is returned.
  722. /// * If the value is larger/smaller than the largest/smallest integer,
  723. /// the largest/smallest integer is returned (saturation).
  724. /// * Otherwise the result of rounding the value towards zero is returned.
  725. ///
  726. /// The scalar width of the type given in operand 1 must be equal to, or
  727. /// smaller than, the scalar result type width. It may end up being smaller
  728. /// than the result width as a result of integer type legalization.
  729. ///
  730. /// After converting to the scalar integer type in operand 1, the value is
  731. /// extended to the result VT. FP_TO_SINT_SAT sign extends and FP_TO_UINT_SAT
  732. /// zero extends.
  733. FP_TO_SINT_SAT,
  734. FP_TO_UINT_SAT,
  735. /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type
  736. /// down to the precision of the destination VT. TRUNC is a flag, which is
  737. /// always an integer that is zero or one. If TRUNC is 0, this is a
  738. /// normal rounding, if it is 1, this FP_ROUND is known to not change the
  739. /// value of Y.
  740. ///
  741. /// The TRUNC = 1 case is used in cases where we know that the value will
  742. /// not be modified by the node, because Y is not using any of the extra
  743. /// precision of source type. This allows certain transformations like
  744. /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for
  745. /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed.
  746. FP_ROUND,
  747. /// Returns current rounding mode:
  748. /// -1 Undefined
  749. /// 0 Round to 0
  750. /// 1 Round to nearest, ties to even
  751. /// 2 Round to +inf
  752. /// 3 Round to -inf
  753. /// 4 Round to nearest, ties to zero
  754. /// Result is rounding mode and chain. Input is a chain.
  755. GET_ROUNDING,
  756. /// Set rounding mode.
  757. /// The first operand is a chain pointer. The second specifies the required
  758. /// rounding mode, encoded in the same way as used in '``GET_ROUNDING``'.
  759. SET_ROUNDING,
  760. /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
  761. FP_EXTEND,
  762. /// BITCAST - This operator converts between integer, vector and FP
  763. /// values, as if the value was stored to memory with one type and loaded
  764. /// from the same address with the other type (or equivalently for vector
  765. /// format conversions, etc). The source and result are required to have
  766. /// the same bit size (e.g. f32 <-> i32). This can also be used for
  767. /// int-to-int or fp-to-fp conversions, but that is a noop, deleted by
  768. /// getNode().
  769. ///
  770. /// This operator is subtly different from the bitcast instruction from
  771. /// LLVM-IR since this node may change the bits in the register. For
  772. /// example, this occurs on big-endian NEON and big-endian MSA where the
  773. /// layout of the bits in the register depends on the vector type and this
  774. /// operator acts as a shuffle operation for some vector type combinations.
  775. BITCAST,
  776. /// ADDRSPACECAST - This operator converts between pointers of different
  777. /// address spaces.
  778. ADDRSPACECAST,
  779. /// FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions
  780. /// and truncation for half-precision (16 bit) floating numbers. These nodes
  781. /// form a semi-softened interface for dealing with f16 (as an i16), which
  782. /// is often a storage-only type but has native conversions.
  783. FP16_TO_FP,
  784. FP_TO_FP16,
  785. STRICT_FP16_TO_FP,
  786. STRICT_FP_TO_FP16,
  787. /// BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions
  788. /// and truncation for bfloat16. These nodes form a semi-softened interface
  789. /// for dealing with bf16 (as an i16), which is often a storage-only type but
  790. /// has native conversions.
  791. BF16_TO_FP,
  792. FP_TO_BF16,
  793. /// Perform various unary floating-point operations inspired by libm. For
  794. /// FPOWI, the result is undefined if if the integer operand doesn't fit into
  795. /// sizeof(int).
  796. FNEG,
  797. FABS,
  798. FSQRT,
  799. FCBRT,
  800. FSIN,
  801. FCOS,
  802. FPOWI,
  803. FPOW,
  804. FLOG,
  805. FLOG2,
  806. FLOG10,
  807. FEXP,
  808. FEXP2,
  809. FCEIL,
  810. FTRUNC,
  811. FRINT,
  812. FNEARBYINT,
  813. FROUND,
  814. FROUNDEVEN,
  815. FFLOOR,
  816. LROUND,
  817. LLROUND,
  818. LRINT,
  819. LLRINT,
  820. /// FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two
  821. /// values.
  822. //
  823. /// In the case where a single input is a NaN (either signaling or quiet),
  824. /// the non-NaN input is returned.
  825. ///
  826. /// The return value of (FMINNUM 0.0, -0.0) could be either 0.0 or -0.0.
  827. FMINNUM,
  828. FMAXNUM,
  829. /// FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimum or maximum on
  830. /// two values, following the IEEE-754 2008 definition. This differs from
  831. /// FMINNUM/FMAXNUM in the handling of signaling NaNs. If one input is a
  832. /// signaling NaN, returns a quiet NaN.
  833. FMINNUM_IEEE,
  834. FMAXNUM_IEEE,
  835. /// FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0
  836. /// as less than 0.0. While FMINNUM_IEEE/FMAXNUM_IEEE follow IEEE 754-2008
  837. /// semantics, FMINIMUM/FMAXIMUM follow IEEE 754-2018 draft semantics.
  838. FMINIMUM,
  839. FMAXIMUM,
  840. /// FSINCOS - Compute both fsin and fcos as a single operation.
  841. FSINCOS,
  842. /// LOAD and STORE have token chains as their first operand, then the same
  843. /// operands as an LLVM load/store instruction, then an offset node that
  844. /// is added / subtracted from the base pointer to form the address (for
  845. /// indexed memory ops).
  846. LOAD,
  847. STORE,
  848. /// DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
  849. /// to a specified boundary. This node always has two return values: a new
  850. /// stack pointer value and a chain. The first operand is the token chain,
  851. /// the second is the number of bytes to allocate, and the third is the
  852. /// alignment boundary. The size is guaranteed to be a multiple of the
  853. /// stack alignment, and the alignment is guaranteed to be bigger than the
  854. /// stack alignment (if required) or 0 to get standard stack alignment.
  855. DYNAMIC_STACKALLOC,
  856. /// Control flow instructions. These all have token chains.
  857. /// BR - Unconditional branch. The first operand is the chain
  858. /// operand, the second is the MBB to branch to.
  859. BR,
  860. /// BRIND - Indirect branch. The first operand is the chain, the second
  861. /// is the value to branch to, which must be of the same type as the
  862. /// target's pointer type.
  863. BRIND,
  864. /// BR_JT - Jumptable branch. The first operand is the chain, the second
  865. /// is the jumptable index, the last one is the jumptable entry index.
  866. BR_JT,
  867. /// BRCOND - Conditional branch. The first operand is the chain, the
  868. /// second is the condition, the third is the block to branch to if the
  869. /// condition is true. If the type of the condition is not i1, then the
  870. /// high bits must conform to getBooleanContents. If the condition is undef,
  871. /// it nondeterministically jumps to the block.
  872. /// TODO: Its semantics w.r.t undef requires further discussion; we need to
  873. /// make it sure that it is consistent with optimizations in MIR & the
  874. /// meaning of IMPLICIT_DEF. See https://reviews.llvm.org/D92015
  875. BRCOND,
  876. /// BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in
  877. /// that the condition is represented as condition code, and two nodes to
  878. /// compare, rather than as a combined SetCC node. The operands in order
  879. /// are chain, cc, lhs, rhs, block to branch to if condition is true. If
  880. /// condition is undef, it nondeterministically jumps to the block.
  881. BR_CC,
  882. /// INLINEASM - Represents an inline asm block. This node always has two
  883. /// return values: a chain and a flag result. The inputs are as follows:
  884. /// Operand #0 : Input chain.
  885. /// Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string.
  886. /// Operand #2 : a MDNodeSDNode with the !srcloc metadata.
  887. /// Operand #3 : HasSideEffect, IsAlignStack bits.
  888. /// After this, it is followed by a list of operands with this format:
  889. /// ConstantSDNode: Flags that encode whether it is a mem or not, the
  890. /// of operands that follow, etc. See InlineAsm.h.
  891. /// ... however many operands ...
  892. /// Operand #last: Optional, an incoming flag.
  893. ///
  894. /// The variable width operands are required to represent target addressing
  895. /// modes as a single "operand", even though they may have multiple
  896. /// SDOperands.
  897. INLINEASM,
  898. /// INLINEASM_BR - Branching version of inline asm. Used by asm-goto.
  899. INLINEASM_BR,
  900. /// EH_LABEL - Represents a label in mid basic block used to track
  901. /// locations needed for debug and exception handling tables. These nodes
  902. /// take a chain as input and return a chain.
  903. EH_LABEL,
  904. /// ANNOTATION_LABEL - Represents a mid basic block label used by
  905. /// annotations. This should remain within the basic block and be ordered
  906. /// with respect to other call instructions, but loads and stores may float
  907. /// past it.
  908. ANNOTATION_LABEL,
  909. /// CATCHRET - Represents a return from a catch block funclet. Used for
  910. /// MSVC compatible exception handling. Takes a chain operand and a
  911. /// destination basic block operand.
  912. CATCHRET,
  913. /// CLEANUPRET - Represents a return from a cleanup block funclet. Used for
  914. /// MSVC compatible exception handling. Takes only a chain operand.
  915. CLEANUPRET,
  916. /// STACKSAVE - STACKSAVE has one operand, an input chain. It produces a
  917. /// value, the same type as the pointer type for the system, and an output
  918. /// chain.
  919. STACKSAVE,
  920. /// STACKRESTORE has two operands, an input chain and a pointer to restore
  921. /// to it returns an output chain.
  922. STACKRESTORE,
  923. /// CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end
  924. /// of a call sequence, and carry arbitrary information that target might
  925. /// want to know. The first operand is a chain, the rest are specified by
  926. /// the target and not touched by the DAG optimizers.
  927. /// Targets that may use stack to pass call arguments define additional
  928. /// operands:
  929. /// - size of the call frame part that must be set up within the
  930. /// CALLSEQ_START..CALLSEQ_END pair,
  931. /// - part of the call frame prepared prior to CALLSEQ_START.
  932. /// Both these parameters must be constants, their sum is the total call
  933. /// frame size.
  934. /// CALLSEQ_START..CALLSEQ_END pairs may not be nested.
  935. CALLSEQ_START, // Beginning of a call sequence
  936. CALLSEQ_END, // End of a call sequence
  937. /// VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE,
  938. /// and the alignment. It returns a pair of values: the vaarg value and a
  939. /// new chain.
  940. VAARG,
  941. /// VACOPY - VACOPY has 5 operands: an input chain, a destination pointer,
  942. /// a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
  943. /// source.
  944. VACOPY,
  945. /// VAEND, VASTART - VAEND and VASTART have three operands: an input chain,
  946. /// pointer, and a SRCVALUE.
  947. VAEND,
  948. VASTART,
  949. // PREALLOCATED_SETUP - This has 2 operands: an input chain and a SRCVALUE
  950. // with the preallocated call Value.
  951. PREALLOCATED_SETUP,
  952. // PREALLOCATED_ARG - This has 3 operands: an input chain, a SRCVALUE
  953. // with the preallocated call Value, and a constant int.
  954. PREALLOCATED_ARG,
  955. /// SRCVALUE - This is a node type that holds a Value* that is used to
  956. /// make reference to a value in the LLVM IR.
  957. SRCVALUE,
  958. /// MDNODE_SDNODE - This is a node that holdes an MDNode*, which is used to
  959. /// reference metadata in the IR.
  960. MDNODE_SDNODE,
  961. /// PCMARKER - This corresponds to the pcmarker intrinsic.
  962. PCMARKER,
  963. /// READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
  964. /// It produces a chain and one i64 value. The only operand is a chain.
  965. /// If i64 is not legal, the result will be expanded into smaller values.
  966. /// Still, it returns an i64, so targets should set legality for i64.
  967. /// The result is the content of the architecture-specific cycle
  968. /// counter-like register (or other high accuracy low latency clock source).
  969. READCYCLECOUNTER,
  970. /// HANDLENODE node - Used as a handle for various purposes.
  971. HANDLENODE,
  972. /// INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic. It
  973. /// takes as input a token chain, the pointer to the trampoline, the pointer
  974. /// to the nested function, the pointer to pass for the 'nest' parameter, a
  975. /// SRCVALUE for the trampoline and another for the nested function
  976. /// (allowing targets to access the original Function*).
  977. /// It produces a token chain as output.
  978. INIT_TRAMPOLINE,
  979. /// ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
  980. /// It takes a pointer to the trampoline and produces a (possibly) new
  981. /// pointer to the same trampoline with platform-specific adjustments
  982. /// applied. The pointer it returns points to an executable block of code.
  983. ADJUST_TRAMPOLINE,
  984. /// TRAP - Trapping instruction
  985. TRAP,
  986. /// DEBUGTRAP - Trap intended to get the attention of a debugger.
  987. DEBUGTRAP,
  988. /// UBSANTRAP - Trap with an immediate describing the kind of sanitizer
  989. /// failure.
  990. UBSANTRAP,
  991. /// PREFETCH - This corresponds to a prefetch intrinsic. The first operand
  992. /// is the chain. The other operands are the address to prefetch,
  993. /// read / write specifier, locality specifier and instruction / data cache
  994. /// specifier.
  995. PREFETCH,
  996. /// ARITH_FENCE - This corresponds to a arithmetic fence intrinsic. Both its
  997. /// operand and output are the same floating type.
  998. ARITH_FENCE,
  999. /// MEMBARRIER - Compiler barrier only; generate a no-op.
  1000. MEMBARRIER,
  1001. /// OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope)
  1002. /// This corresponds to the fence instruction. It takes an input chain, and
  1003. /// two integer constants: an AtomicOrdering and a SynchronizationScope.
  1004. ATOMIC_FENCE,
  1005. /// Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr)
  1006. /// This corresponds to "load atomic" instruction.
  1007. ATOMIC_LOAD,
  1008. /// OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val)
  1009. /// This corresponds to "store atomic" instruction.
  1010. ATOMIC_STORE,
  1011. /// Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap)
  1012. /// For double-word atomic operations:
  1013. /// ValLo, ValHi, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmpLo, cmpHi,
  1014. /// swapLo, swapHi)
  1015. /// This corresponds to the cmpxchg instruction.
  1016. ATOMIC_CMP_SWAP,
  1017. /// Val, Success, OUTCHAIN
  1018. /// = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap)
  1019. /// N.b. this is still a strong cmpxchg operation, so
  1020. /// Success == "Val == cmp".
  1021. ATOMIC_CMP_SWAP_WITH_SUCCESS,
  1022. /// Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt)
  1023. /// Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt)
  1024. /// For double-word atomic operations:
  1025. /// ValLo, ValHi, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amtLo, amtHi)
  1026. /// ValLo, ValHi, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amtLo, amtHi)
  1027. /// These correspond to the atomicrmw instruction.
  1028. ATOMIC_SWAP,
  1029. ATOMIC_LOAD_ADD,
  1030. ATOMIC_LOAD_SUB,
  1031. ATOMIC_LOAD_AND,
  1032. ATOMIC_LOAD_CLR,
  1033. ATOMIC_LOAD_OR,
  1034. ATOMIC_LOAD_XOR,
  1035. ATOMIC_LOAD_NAND,
  1036. ATOMIC_LOAD_MIN,
  1037. ATOMIC_LOAD_MAX,
  1038. ATOMIC_LOAD_UMIN,
  1039. ATOMIC_LOAD_UMAX,
  1040. ATOMIC_LOAD_FADD,
  1041. ATOMIC_LOAD_FSUB,
  1042. ATOMIC_LOAD_FMAX,
  1043. ATOMIC_LOAD_FMIN,
  1044. ATOMIC_LOAD_UINC_WRAP,
  1045. ATOMIC_LOAD_UDEC_WRAP,
  1046. // Masked load and store - consecutive vector load and store operations
  1047. // with additional mask operand that prevents memory accesses to the
  1048. // masked-off lanes.
  1049. //
  1050. // Val, OutChain = MLOAD(BasePtr, Mask, PassThru)
  1051. // OutChain = MSTORE(Value, BasePtr, Mask)
  1052. MLOAD,
  1053. MSTORE,
  1054. // Masked gather and scatter - load and store operations for a vector of
  1055. // random addresses with additional mask operand that prevents memory
  1056. // accesses to the masked-off lanes.
  1057. //
  1058. // Val, OutChain = GATHER(InChain, PassThru, Mask, BasePtr, Index, Scale)
  1059. // OutChain = SCATTER(InChain, Value, Mask, BasePtr, Index, Scale)
  1060. //
  1061. // The Index operand can have more vector elements than the other operands
  1062. // due to type legalization. The extra elements are ignored.
  1063. MGATHER,
  1064. MSCATTER,
  1065. /// This corresponds to the llvm.lifetime.* intrinsics. The first operand
  1066. /// is the chain and the second operand is the alloca pointer.
  1067. LIFETIME_START,
  1068. LIFETIME_END,
  1069. /// GC_TRANSITION_START/GC_TRANSITION_END - These operators mark the
  1070. /// beginning and end of GC transition sequence, and carry arbitrary
  1071. /// information that target might need for lowering. The first operand is
  1072. /// a chain, the rest are specified by the target and not touched by the DAG
  1073. /// optimizers. GC_TRANSITION_START..GC_TRANSITION_END pairs may not be
  1074. /// nested.
  1075. GC_TRANSITION_START,
  1076. GC_TRANSITION_END,
  1077. /// GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of
  1078. /// the most recent dynamic alloca. For most targets that would be 0, but
  1079. /// for some others (e.g. PowerPC, PowerPC64) that would be compile-time
  1080. /// known nonzero constant. The only operand here is the chain.
  1081. GET_DYNAMIC_AREA_OFFSET,
  1082. /// Pseudo probe for AutoFDO, as a place holder in a basic block to improve
  1083. /// the sample counts quality.
  1084. PSEUDO_PROBE,
  1085. /// VSCALE(IMM) - Returns the runtime scaling factor used to calculate the
  1086. /// number of elements within a scalable vector. IMM is a constant integer
  1087. /// multiplier that is applied to the runtime value.
  1088. VSCALE,
  1089. /// Generic reduction nodes. These nodes represent horizontal vector
  1090. /// reduction operations, producing a scalar result.
  1091. /// The SEQ variants perform reductions in sequential order. The first
  1092. /// operand is an initial scalar accumulator value, and the second operand
  1093. /// is the vector to reduce.
  1094. /// E.g. RES = VECREDUCE_SEQ_FADD f32 ACC, <4 x f32> SRC_VEC
  1095. /// ... is equivalent to
  1096. /// RES = (((ACC + SRC_VEC[0]) + SRC_VEC[1]) + SRC_VEC[2]) + SRC_VEC[3]
  1097. VECREDUCE_SEQ_FADD,
  1098. VECREDUCE_SEQ_FMUL,
  1099. /// These reductions have relaxed evaluation order semantics, and have a
  1100. /// single vector operand. The order of evaluation is unspecified. For
  1101. /// pow-of-2 vectors, one valid legalizer expansion is to use a tree
  1102. /// reduction, i.e.:
  1103. /// For RES = VECREDUCE_FADD <8 x f16> SRC_VEC
  1104. /// PART_RDX = FADD SRC_VEC[0:3], SRC_VEC[4:7]
  1105. /// PART_RDX2 = FADD PART_RDX[0:1], PART_RDX[2:3]
  1106. /// RES = FADD PART_RDX2[0], PART_RDX2[1]
  1107. /// For non-pow-2 vectors, this can be computed by extracting each element
  1108. /// and performing the operation as if it were scalarized.
  1109. VECREDUCE_FADD,
  1110. VECREDUCE_FMUL,
  1111. /// FMIN/FMAX nodes can have flags, for NaN/NoNaN variants.
  1112. VECREDUCE_FMAX,
  1113. VECREDUCE_FMIN,
  1114. /// Integer reductions may have a result type larger than the vector element
  1115. /// type. However, the reduction is performed using the vector element type
  1116. /// and the value in the top bits is unspecified.
  1117. VECREDUCE_ADD,
  1118. VECREDUCE_MUL,
  1119. VECREDUCE_AND,
  1120. VECREDUCE_OR,
  1121. VECREDUCE_XOR,
  1122. VECREDUCE_SMAX,
  1123. VECREDUCE_SMIN,
  1124. VECREDUCE_UMAX,
  1125. VECREDUCE_UMIN,
  1126. // The `llvm.experimental.stackmap` intrinsic.
  1127. // Operands: input chain, glue, <id>, <numShadowBytes>, [live0[, live1...]]
  1128. // Outputs: output chain, glue
  1129. STACKMAP,
  1130. // The `llvm.experimental.patchpoint.*` intrinsic.
  1131. // Operands: input chain, [glue], reg-mask, <id>, <numShadowBytes>, callee,
  1132. // <numArgs>, cc, ...
  1133. // Outputs: [rv], output chain, glue
  1134. PATCHPOINT,
  1135. // Vector Predication
  1136. #define BEGIN_REGISTER_VP_SDNODE(VPSDID, ...) VPSDID,
  1137. #include "llvm/IR/VPIntrinsics.def"
  1138. /// BUILTIN_OP_END - This must be the last enum value in this list.
  1139. /// The target-specific pre-isel opcode values start here.
  1140. BUILTIN_OP_END
  1141. };
  1142. /// FIRST_TARGET_STRICTFP_OPCODE - Target-specific pre-isel operations
  1143. /// which cannot raise FP exceptions should be less than this value.
  1144. /// Those that do must not be less than this value.
  1145. static const int FIRST_TARGET_STRICTFP_OPCODE = BUILTIN_OP_END + 400;
  1146. /// FIRST_TARGET_MEMORY_OPCODE - Target-specific pre-isel operations
  1147. /// which do not reference a specific memory location should be less than
  1148. /// this value. Those that do must not be less than this value, and can
  1149. /// be used with SelectionDAG::getMemIntrinsicNode.
  1150. static const int FIRST_TARGET_MEMORY_OPCODE = BUILTIN_OP_END + 500;
  1151. /// Whether this is bitwise logic opcode.
  1152. inline bool isBitwiseLogicOp(unsigned Opcode) {
  1153. return Opcode == ISD::AND || Opcode == ISD::OR || Opcode == ISD::XOR;
  1154. }
  1155. /// Get underlying scalar opcode for VECREDUCE opcode.
  1156. /// For example ISD::AND for ISD::VECREDUCE_AND.
  1157. NodeType getVecReduceBaseOpcode(unsigned VecReduceOpcode);
  1158. /// Whether this is a vector-predicated Opcode.
  1159. bool isVPOpcode(unsigned Opcode);
  1160. /// Whether this is a vector-predicated binary operation opcode.
  1161. bool isVPBinaryOp(unsigned Opcode);
  1162. /// Whether this is a vector-predicated reduction opcode.
  1163. bool isVPReduction(unsigned Opcode);
  1164. /// The operand position of the vector mask.
  1165. std::optional<unsigned> getVPMaskIdx(unsigned Opcode);
  1166. /// The operand position of the explicit vector length parameter.
  1167. std::optional<unsigned> getVPExplicitVectorLengthIdx(unsigned Opcode);
  1168. //===--------------------------------------------------------------------===//
  1169. /// MemIndexedMode enum - This enum defines the load / store indexed
  1170. /// addressing modes.
  1171. ///
  1172. /// UNINDEXED "Normal" load / store. The effective address is already
  1173. /// computed and is available in the base pointer. The offset
  1174. /// operand is always undefined. In addition to producing a
  1175. /// chain, an unindexed load produces one value (result of the
  1176. /// load); an unindexed store does not produce a value.
  1177. ///
  1178. /// PRE_INC Similar to the unindexed mode where the effective address is
  1179. /// PRE_DEC the value of the base pointer add / subtract the offset.
  1180. /// It considers the computation as being folded into the load /
  1181. /// store operation (i.e. the load / store does the address
  1182. /// computation as well as performing the memory transaction).
  1183. /// The base operand is always undefined. In addition to
  1184. /// producing a chain, pre-indexed load produces two values
  1185. /// (result of the load and the result of the address
  1186. /// computation); a pre-indexed store produces one value (result
  1187. /// of the address computation).
  1188. ///
  1189. /// POST_INC The effective address is the value of the base pointer. The
  1190. /// POST_DEC value of the offset operand is then added to / subtracted
  1191. /// from the base after memory transaction. In addition to
  1192. /// producing a chain, post-indexed load produces two values
  1193. /// (the result of the load and the result of the base +/- offset
  1194. /// computation); a post-indexed store produces one value (the
  1195. /// the result of the base +/- offset computation).
  1196. enum MemIndexedMode { UNINDEXED = 0, PRE_INC, PRE_DEC, POST_INC, POST_DEC };
  1197. static const int LAST_INDEXED_MODE = POST_DEC + 1;
  1198. //===--------------------------------------------------------------------===//
  1199. /// MemIndexType enum - This enum defines how to interpret MGATHER/SCATTER's
  1200. /// index parameter when calculating addresses.
  1201. ///
  1202. /// SIGNED_SCALED Addr = Base + ((signed)Index * Scale)
  1203. /// UNSIGNED_SCALED Addr = Base + ((unsigned)Index * Scale)
  1204. ///
  1205. /// NOTE: The value of Scale is typically only known to the node owning the
  1206. /// IndexType, with a value of 1 the equivalent of being unscaled.
  1207. enum MemIndexType { SIGNED_SCALED = 0, UNSIGNED_SCALED };
  1208. static const int LAST_MEM_INDEX_TYPE = UNSIGNED_SCALED + 1;
  1209. inline bool isIndexTypeSigned(MemIndexType IndexType) {
  1210. return IndexType == SIGNED_SCALED;
  1211. }
  1212. //===--------------------------------------------------------------------===//
  1213. /// LoadExtType enum - This enum defines the three variants of LOADEXT
  1214. /// (load with extension).
  1215. ///
  1216. /// SEXTLOAD loads the integer operand and sign extends it to a larger
  1217. /// integer result type.
  1218. /// ZEXTLOAD loads the integer operand and zero extends it to a larger
  1219. /// integer result type.
  1220. /// EXTLOAD is used for two things: floating point extending loads and
  1221. /// integer extending loads [the top bits are undefined].
  1222. enum LoadExtType { NON_EXTLOAD = 0, EXTLOAD, SEXTLOAD, ZEXTLOAD };
  1223. static const int LAST_LOADEXT_TYPE = ZEXTLOAD + 1;
  1224. NodeType getExtForLoadExtType(bool IsFP, LoadExtType);
  1225. //===--------------------------------------------------------------------===//
  1226. /// ISD::CondCode enum - These are ordered carefully to make the bitfields
  1227. /// below work out, when considering SETFALSE (something that never exists
  1228. /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered
  1229. /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
  1230. /// to. If the "N" column is 1, the result of the comparison is undefined if
  1231. /// the input is a NAN.
  1232. ///
  1233. /// All of these (except for the 'always folded ops') should be handled for
  1234. /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
  1235. /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
  1236. ///
  1237. /// Note that these are laid out in a specific order to allow bit-twiddling
  1238. /// to transform conditions.
  1239. enum CondCode {
  1240. // Opcode N U L G E Intuitive operation
  1241. SETFALSE, // 0 0 0 0 Always false (always folded)
  1242. SETOEQ, // 0 0 0 1 True if ordered and equal
  1243. SETOGT, // 0 0 1 0 True if ordered and greater than
  1244. SETOGE, // 0 0 1 1 True if ordered and greater than or equal
  1245. SETOLT, // 0 1 0 0 True if ordered and less than
  1246. SETOLE, // 0 1 0 1 True if ordered and less than or equal
  1247. SETONE, // 0 1 1 0 True if ordered and operands are unequal
  1248. SETO, // 0 1 1 1 True if ordered (no nans)
  1249. SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y)
  1250. SETUEQ, // 1 0 0 1 True if unordered or equal
  1251. SETUGT, // 1 0 1 0 True if unordered or greater than
  1252. SETUGE, // 1 0 1 1 True if unordered, greater than, or equal
  1253. SETULT, // 1 1 0 0 True if unordered or less than
  1254. SETULE, // 1 1 0 1 True if unordered, less than, or equal
  1255. SETUNE, // 1 1 1 0 True if unordered or not equal
  1256. SETTRUE, // 1 1 1 1 Always true (always folded)
  1257. // Don't care operations: undefined if the input is a nan.
  1258. SETFALSE2, // 1 X 0 0 0 Always false (always folded)
  1259. SETEQ, // 1 X 0 0 1 True if equal
  1260. SETGT, // 1 X 0 1 0 True if greater than
  1261. SETGE, // 1 X 0 1 1 True if greater than or equal
  1262. SETLT, // 1 X 1 0 0 True if less than
  1263. SETLE, // 1 X 1 0 1 True if less than or equal
  1264. SETNE, // 1 X 1 1 0 True if not equal
  1265. SETTRUE2, // 1 X 1 1 1 Always true (always folded)
  1266. SETCC_INVALID // Marker value.
  1267. };
  1268. /// Return true if this is a setcc instruction that performs a signed
  1269. /// comparison when used with integer operands.
  1270. inline bool isSignedIntSetCC(CondCode Code) {
  1271. return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
  1272. }
  1273. /// Return true if this is a setcc instruction that performs an unsigned
  1274. /// comparison when used with integer operands.
  1275. inline bool isUnsignedIntSetCC(CondCode Code) {
  1276. return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
  1277. }
  1278. /// Return true if this is a setcc instruction that performs an equality
  1279. /// comparison when used with integer operands.
  1280. inline bool isIntEqualitySetCC(CondCode Code) {
  1281. return Code == SETEQ || Code == SETNE;
  1282. }
  1283. /// Return true if the specified condition returns true if the two operands to
  1284. /// the condition are equal. Note that if one of the two operands is a NaN,
  1285. /// this value is meaningless.
  1286. inline bool isTrueWhenEqual(CondCode Cond) { return ((int)Cond & 1) != 0; }
  1287. /// This function returns 0 if the condition is always false if an operand is
  1288. /// a NaN, 1 if the condition is always true if the operand is a NaN, and 2 if
  1289. /// the condition is undefined if the operand is a NaN.
  1290. inline unsigned getUnorderedFlavor(CondCode Cond) {
  1291. return ((int)Cond >> 3) & 3;
  1292. }
  1293. /// Return the operation corresponding to !(X op Y), where 'op' is a valid
  1294. /// SetCC operation.
  1295. CondCode getSetCCInverse(CondCode Operation, EVT Type);
  1296. inline bool isExtOpcode(unsigned Opcode) {
  1297. return Opcode == ISD::ANY_EXTEND || Opcode == ISD::ZERO_EXTEND ||
  1298. Opcode == ISD::SIGN_EXTEND;
  1299. }
  1300. namespace GlobalISel {
  1301. /// Return the operation corresponding to !(X op Y), where 'op' is a valid
  1302. /// SetCC operation. The U bit of the condition code has different meanings
  1303. /// between floating point and integer comparisons and LLT's don't provide
  1304. /// this distinction. As such we need to be told whether the comparison is
  1305. /// floating point or integer-like. Pointers should use integer-like
  1306. /// comparisons.
  1307. CondCode getSetCCInverse(CondCode Operation, bool isIntegerLike);
  1308. } // end namespace GlobalISel
  1309. /// Return the operation corresponding to (Y op X) when given the operation
  1310. /// for (X op Y).
  1311. CondCode getSetCCSwappedOperands(CondCode Operation);
  1312. /// Return the result of a logical OR between different comparisons of
  1313. /// identical values: ((X op1 Y) | (X op2 Y)). This function returns
  1314. /// SETCC_INVALID if it is not possible to represent the resultant comparison.
  1315. CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, EVT Type);
  1316. /// Return the result of a logical AND between different comparisons of
  1317. /// identical values: ((X op1 Y) & (X op2 Y)). This function returns
  1318. /// SETCC_INVALID if it is not possible to represent the resultant comparison.
  1319. CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, EVT Type);
  1320. } // namespace ISD
  1321. } // namespace llvm
  1322. #endif
  1323. #ifdef __GNUC__
  1324. #pragma GCC diagnostic pop
  1325. #endif