ISDOpcodes.h 60 KB

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