ISDOpcodes.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. //===-- llvm/CodeGen/ISDOpcodes.h - CodeGen opcodes -------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file declares codegen opcodes and related utilities.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CODEGEN_ISDOPCODES_H
  14. #define LLVM_CODEGEN_ISDOPCODES_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, AssertZext,
  51. /// Various leaf nodes.
  52. BasicBlock, VALUETYPE, CONDCODE, Register, RegisterMask,
  53. Constant, ConstantFP,
  54. GlobalAddress, GlobalTLSAddress, FrameIndex,
  55. JumpTable, ConstantPool, ExternalSymbol, BlockAddress,
  56. /// The address of the GOT
  57. GLOBAL_OFFSET_TABLE,
  58. /// FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and
  59. /// llvm.returnaddress on the DAG. These nodes take one operand, the index
  60. /// of the frame or return address to return. An index of zero corresponds
  61. /// to the current function's frame or return address, an index of one to
  62. /// the parent's frame or return address, and so on.
  63. FRAMEADDR, RETURNADDR,
  64. /// LOCAL_RECOVER - Represents the llvm.localrecover intrinsic.
  65. /// Materializes the offset from the local object pointer of another
  66. /// function to a particular local object passed to llvm.localescape. The
  67. /// operand is the MCSymbol label used to represent this offset, since
  68. /// typically the offset is not known until after code generation of the
  69. /// parent.
  70. LOCAL_RECOVER,
  71. /// READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on
  72. /// the DAG, which implements the named register global variables extension.
  73. READ_REGISTER,
  74. WRITE_REGISTER,
  75. /// FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to
  76. /// first (possible) on-stack argument. This is needed for correct stack
  77. /// adjustment during unwind.
  78. FRAME_TO_ARGS_OFFSET,
  79. /// OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents
  80. /// 'eh_return' gcc dwarf builtin, which is used to return from
  81. /// exception. The general meaning is: adjust stack by OFFSET and pass
  82. /// execution to HANDLER. Many platform-related details also :)
  83. EH_RETURN,
  84. /// RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer)
  85. /// This corresponds to the eh.sjlj.setjmp intrinsic.
  86. /// It takes an input chain and a pointer to the jump buffer as inputs
  87. /// and returns an outchain.
  88. EH_SJLJ_SETJMP,
  89. /// OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer)
  90. /// This corresponds to the eh.sjlj.longjmp intrinsic.
  91. /// It takes an input chain and a pointer to the jump buffer as inputs
  92. /// and returns an outchain.
  93. EH_SJLJ_LONGJMP,
  94. /// TargetConstant* - Like Constant*, but the DAG does not do any folding,
  95. /// simplification, or lowering of the constant. They are used for constants
  96. /// which are known to fit in the immediate fields of their users, or for
  97. /// carrying magic numbers which are not values which need to be
  98. /// materialized in registers.
  99. TargetConstant,
  100. TargetConstantFP,
  101. /// TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
  102. /// anything else with this node, and this is valid in the target-specific
  103. /// dag, turning into a GlobalAddress operand.
  104. TargetGlobalAddress,
  105. TargetGlobalTLSAddress,
  106. TargetFrameIndex,
  107. TargetJumpTable,
  108. TargetConstantPool,
  109. TargetExternalSymbol,
  110. TargetBlockAddress,
  111. MCSymbol,
  112. /// TargetIndex - Like a constant pool entry, but with completely
  113. /// target-dependent semantics. Holds target flags, a 32-bit index, and a
  114. /// 64-bit index. Targets can use this however they like.
  115. TargetIndex,
  116. /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
  117. /// This node represents a target intrinsic function with no side effects.
  118. /// The first operand is the ID number of the intrinsic from the
  119. /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The
  120. /// node returns the result of the intrinsic.
  121. INTRINSIC_WO_CHAIN,
  122. /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
  123. /// This node represents a target intrinsic function with side effects that
  124. /// returns a result. The first operand is a chain pointer. The second is
  125. /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The
  126. /// operands to the intrinsic follow. The node has two results, the result
  127. /// of the intrinsic and an output chain.
  128. INTRINSIC_W_CHAIN,
  129. /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
  130. /// This node represents a target intrinsic function with side effects that
  131. /// does not return a result. The first operand is a chain pointer. The
  132. /// second is the ID number of the intrinsic from the llvm::Intrinsic
  133. /// namespace. The operands to the intrinsic follow.
  134. INTRINSIC_VOID,
  135. /// CopyToReg - This node has three operands: a chain, a register number to
  136. /// set to this value, and a value.
  137. CopyToReg,
  138. /// CopyFromReg - This node indicates that the input value is a virtual or
  139. /// physical register that is defined outside of the scope of this
  140. /// SelectionDAG. The register is available from the RegisterSDNode object.
  141. CopyFromReg,
  142. /// UNDEF - An undefined node.
  143. UNDEF,
  144. /// EXTRACT_ELEMENT - This is used to get the lower or upper (determined by
  145. /// a Constant, which is required to be operand #1) half of the integer or
  146. /// float value specified as operand #0. This is only for use before
  147. /// legalization, for values that will be broken into multiple registers.
  148. EXTRACT_ELEMENT,
  149. /// BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
  150. /// Given two values of the same integer value type, this produces a value
  151. /// twice as big. Like EXTRACT_ELEMENT, this can only be used before
  152. /// legalization.
  153. BUILD_PAIR,
  154. /// MERGE_VALUES - This node takes multiple discrete operands and returns
  155. /// them all as its individual results. This nodes has exactly the same
  156. /// number of inputs and outputs. This node is useful for some pieces of the
  157. /// code generator that want to think about a single node with multiple
  158. /// results, not multiple nodes.
  159. MERGE_VALUES,
  160. /// Simple integer binary arithmetic operators.
  161. ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
  162. /// SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing
  163. /// a signed/unsigned value of type i[2*N], and return the full value as
  164. /// two results, each of type iN.
  165. SMUL_LOHI, UMUL_LOHI,
  166. /// SDIVREM/UDIVREM - Divide two integers and produce both a quotient and
  167. /// remainder result.
  168. SDIVREM, UDIVREM,
  169. /// CARRY_FALSE - This node is used when folding other nodes,
  170. /// like ADDC/SUBC, which indicate the carry result is always false.
  171. CARRY_FALSE,
  172. /// Carry-setting nodes for multiple precision addition and subtraction.
  173. /// These nodes take two operands of the same value type, and produce two
  174. /// results. The first result is the normal add or sub result, the second
  175. /// result is the carry flag result.
  176. ADDC, SUBC,
  177. /// Carry-using nodes for multiple precision addition and subtraction. These
  178. /// nodes take three operands: The first two are the normal lhs and rhs to
  179. /// the add or sub, and the third is the input carry flag. These nodes
  180. /// produce two results; the normal result of the add or sub, and the output
  181. /// carry flag. These nodes both read and write a carry flag to allow them
  182. /// to them to be chained together for add and sub of arbitrarily large
  183. /// values.
  184. ADDE, SUBE,
  185. /// RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
  186. /// These nodes take two operands: the normal LHS and RHS to the add. They
  187. /// produce two results: the normal result of the add, and a boolean that
  188. /// indicates if an overflow occurred (*not* a flag, because it may be store
  189. /// to memory, etc.). If the type of the boolean is not i1 then the high
  190. /// bits conform to getBooleanContents.
  191. /// These nodes are generated from llvm.[su]add.with.overflow intrinsics.
  192. SADDO, UADDO,
  193. /// Same for subtraction.
  194. SSUBO, USUBO,
  195. /// Same for multiplication.
  196. SMULO, UMULO,
  197. /// Simple binary floating point operators.
  198. FADD, FSUB, FMUL, FDIV, FREM,
  199. /// FMA - Perform a * b + c with no intermediate rounding step.
  200. FMA,
  201. /// FMAD - Perform a * b + c, while getting the same result as the
  202. /// separately rounded operations.
  203. FMAD,
  204. /// FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This
  205. /// DAG node does not require that X and Y have the same type, just that
  206. /// they are both floating point. X and the result must have the same type.
  207. /// FCOPYSIGN(f32, f64) is allowed.
  208. FCOPYSIGN,
  209. /// INT = FGETSIGN(FP) - Return the sign bit of the specified floating point
  210. /// value as an integer 0/1 value.
  211. FGETSIGN,
  212. /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the
  213. /// specified, possibly variable, elements. The number of elements is
  214. /// required to be a power of two. The types of the operands must all be
  215. /// the same and must match the vector element type, except that integer
  216. /// types are allowed to be larger than the element type, in which case
  217. /// the operands are implicitly truncated.
  218. BUILD_VECTOR,
  219. /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
  220. /// at IDX replaced with VAL. If the type of VAL is larger than the vector
  221. /// element type then VAL is truncated before replacement.
  222. INSERT_VECTOR_ELT,
  223. /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
  224. /// identified by the (potentially variable) element number IDX. If the
  225. /// return type is an integer type larger than the element type of the
  226. /// vector, the result is extended to the width of the return type.
  227. EXTRACT_VECTOR_ELT,
  228. /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
  229. /// vector type with the same length and element type, this produces a
  230. /// concatenated vector result value, with length equal to the sum of the
  231. /// lengths of the input vectors.
  232. CONCAT_VECTORS,
  233. /// INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector
  234. /// with VECTOR2 inserted into VECTOR1 at the (potentially
  235. /// variable) element number IDX, which must be a multiple of the
  236. /// VECTOR2 vector length. The elements of VECTOR1 starting at
  237. /// IDX are overwritten with VECTOR2. Elements IDX through
  238. /// vector_length(VECTOR2) must be valid VECTOR1 indices.
  239. INSERT_SUBVECTOR,
  240. /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
  241. /// vector value) starting with the element number IDX, which must be a
  242. /// constant multiple of the result vector length.
  243. EXTRACT_SUBVECTOR,
  244. /// VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as
  245. /// VEC1/VEC2. A VECTOR_SHUFFLE node also contains an array of constant int
  246. /// values that indicate which value (or undef) each result element will
  247. /// get. These constant ints are accessible through the
  248. /// ShuffleVectorSDNode class. This is quite similar to the Altivec
  249. /// 'vperm' instruction, except that the indices must be constants and are
  250. /// in terms of the element size of VEC1/VEC2, not in terms of bytes.
  251. VECTOR_SHUFFLE,
  252. /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
  253. /// scalar value into element 0 of the resultant vector type. The top
  254. /// elements 1 to N-1 of the N-element vector are undefined. The type
  255. /// of the operand must match the vector element type, except when they
  256. /// are integer types. In this case the operand is allowed to be wider
  257. /// than the vector element type, and is implicitly truncated to it.
  258. SCALAR_TO_VECTOR,
  259. /// MULHU/MULHS - Multiply high - Multiply two integers of type iN,
  260. /// producing an unsigned/signed value of type i[2*N], then return the top
  261. /// part.
  262. MULHU, MULHS,
  263. /// [US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned
  264. /// integers.
  265. SMIN, SMAX, UMIN, UMAX,
  266. /// Bitwise operators - logical and, logical or, logical xor.
  267. AND, OR, XOR,
  268. /// Shift and rotation operations. After legalization, the type of the
  269. /// shift amount is known to be TLI.getShiftAmountTy(). Before legalization
  270. /// the shift amount can be any type, but care must be taken to ensure it is
  271. /// large enough. TLI.getShiftAmountTy() is i8 on some targets, but before
  272. /// legalization, types like i1024 can occur and i8 doesn't have enough bits
  273. /// to represent the shift amount.
  274. /// When the 1st operand is a vector, the shift amount must be in the same
  275. /// type. (TLI.getShiftAmountTy() will return the same type when the input
  276. /// type is a vector.)
  277. SHL, SRA, SRL, ROTL, ROTR,
  278. /// Byte Swap and Counting operators.
  279. BSWAP, CTTZ, CTLZ, CTPOP,
  280. /// Bit counting operators with an undefined result for zero inputs.
  281. CTTZ_ZERO_UNDEF, CTLZ_ZERO_UNDEF,
  282. /// Select(COND, TRUEVAL, FALSEVAL). If the type of the boolean COND is not
  283. /// i1 then the high bits must conform to getBooleanContents.
  284. SELECT,
  285. /// Select with a vector condition (op #0) and two vector operands (ops #1
  286. /// and #2), returning a vector result. All vectors have the same length.
  287. /// Much like the scalar select and setcc, each bit in the condition selects
  288. /// whether the corresponding result element is taken from op #1 or op #2.
  289. /// At first, the VSELECT condition is of vXi1 type. Later, targets may
  290. /// change the condition type in order to match the VSELECT node using a
  291. /// pattern. The condition follows the BooleanContent format of the target.
  292. VSELECT,
  293. /// Select with condition operator - This selects between a true value and
  294. /// a false value (ops #2 and #3) based on the boolean result of comparing
  295. /// the lhs and rhs (ops #0 and #1) of a conditional expression with the
  296. /// condition code in op #4, a CondCodeSDNode.
  297. SELECT_CC,
  298. /// SetCC operator - This evaluates to a true value iff the condition is
  299. /// true. If the result value type is not i1 then the high bits conform
  300. /// to getBooleanContents. The operands to this are the left and right
  301. /// operands to compare (ops #0, and #1) and the condition code to compare
  302. /// them with (op #2) as a CondCodeSDNode. If the operands are vector types
  303. /// then the result type must also be a vector type.
  304. SETCC,
  305. /// SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
  306. /// integer shift operations, just like ADD/SUB_PARTS. The operation
  307. /// ordering is:
  308. /// [Lo,Hi] = op [LoLHS,HiLHS], Amt
  309. SHL_PARTS, SRA_PARTS, SRL_PARTS,
  310. /// Conversion operators. These are all single input single output
  311. /// operations. For all of these, the result type must be strictly
  312. /// wider or narrower (depending on the operation) than the source
  313. /// type.
  314. /// SIGN_EXTEND - Used for integer types, replicating the sign bit
  315. /// into new bits.
  316. SIGN_EXTEND,
  317. /// ZERO_EXTEND - Used for integer types, zeroing the new bits.
  318. ZERO_EXTEND,
  319. /// ANY_EXTEND - Used for integer types. The high bits are undefined.
  320. ANY_EXTEND,
  321. /// TRUNCATE - Completely drop the high bits.
  322. TRUNCATE,
  323. /// [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
  324. /// depends on the first letter) to floating point.
  325. SINT_TO_FP,
  326. UINT_TO_FP,
  327. /// SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
  328. /// sign extend a small value in a large integer register (e.g. sign
  329. /// extending the low 8 bits of a 32-bit register to fill the top 24 bits
  330. /// with the 7th bit). The size of the smaller type is indicated by the 1th
  331. /// operand, a ValueType node.
  332. SIGN_EXTEND_INREG,
  333. /// ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an
  334. /// in-register any-extension of the low lanes of an integer vector. The
  335. /// result type must have fewer elements than the operand type, and those
  336. /// elements must be larger integer types such that the total size of the
  337. /// operand type and the result type match. Each of the low operand
  338. /// elements is any-extended into the corresponding, wider result
  339. /// elements with the high bits becoming undef.
  340. ANY_EXTEND_VECTOR_INREG,
  341. /// SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an
  342. /// in-register sign-extension of the low lanes of an integer vector. The
  343. /// result type must have fewer elements than the operand type, and those
  344. /// elements must be larger integer types such that the total size of the
  345. /// operand type and the result type match. Each of the low operand
  346. /// elements is sign-extended into the corresponding, wider result
  347. /// elements.
  348. // FIXME: The SIGN_EXTEND_INREG node isn't specifically limited to
  349. // scalars, but it also doesn't handle vectors well. Either it should be
  350. // restricted to scalars or this node (and its handling) should be merged
  351. // into it.
  352. SIGN_EXTEND_VECTOR_INREG,
  353. /// ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an
  354. /// in-register zero-extension of the low lanes of an integer vector. The
  355. /// result type must have fewer elements than the operand type, and those
  356. /// elements must be larger integer types such that the total size of the
  357. /// operand type and the result type match. Each of the low operand
  358. /// elements is zero-extended into the corresponding, wider result
  359. /// elements.
  360. ZERO_EXTEND_VECTOR_INREG,
  361. /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
  362. /// integer.
  363. FP_TO_SINT,
  364. FP_TO_UINT,
  365. /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type
  366. /// down to the precision of the destination VT. TRUNC is a flag, which is
  367. /// always an integer that is zero or one. If TRUNC is 0, this is a
  368. /// normal rounding, if it is 1, this FP_ROUND is known to not change the
  369. /// value of Y.
  370. ///
  371. /// The TRUNC = 1 case is used in cases where we know that the value will
  372. /// not be modified by the node, because Y is not using any of the extra
  373. /// precision of source type. This allows certain transformations like
  374. /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for
  375. /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed.
  376. FP_ROUND,
  377. /// FLT_ROUNDS_ - Returns current rounding mode:
  378. /// -1 Undefined
  379. /// 0 Round to 0
  380. /// 1 Round to nearest
  381. /// 2 Round to +inf
  382. /// 3 Round to -inf
  383. FLT_ROUNDS_,
  384. /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and
  385. /// rounds it to a floating point value. It then promotes it and returns it
  386. /// in a register of the same size. This operation effectively just
  387. /// discards excess precision. The type to round down to is specified by
  388. /// the VT operand, a VTSDNode.
  389. FP_ROUND_INREG,
  390. /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
  391. FP_EXTEND,
  392. /// BITCAST - This operator converts between integer, vector and FP
  393. /// values, as if the value was stored to memory with one type and loaded
  394. /// from the same address with the other type (or equivalently for vector
  395. /// format conversions, etc). The source and result are required to have
  396. /// the same bit size (e.g. f32 <-> i32). This can also be used for
  397. /// int-to-int or fp-to-fp conversions, but that is a noop, deleted by
  398. /// getNode().
  399. BITCAST,
  400. /// ADDRSPACECAST - This operator converts between pointers of different
  401. /// address spaces.
  402. ADDRSPACECAST,
  403. /// CONVERT_RNDSAT - This operator is used to support various conversions
  404. /// between various types (float, signed, unsigned and vectors of those
  405. /// types) with rounding and saturation. NOTE: Avoid using this operator as
  406. /// most target don't support it and the operator might be removed in the
  407. /// future. It takes the following arguments:
  408. /// 0) value
  409. /// 1) dest type (type to convert to)
  410. /// 2) src type (type to convert from)
  411. /// 3) rounding imm
  412. /// 4) saturation imm
  413. /// 5) ISD::CvtCode indicating the type of conversion to do
  414. CONVERT_RNDSAT,
  415. /// FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions
  416. /// and truncation for half-precision (16 bit) floating numbers. These nodes
  417. /// form a semi-softened interface for dealing with f16 (as an i16), which
  418. /// is often a storage-only type but has native conversions.
  419. FP16_TO_FP, FP_TO_FP16,
  420. /// FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
  421. /// FLOG, FLOG2, FLOG10, FEXP, FEXP2,
  422. /// FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR - Perform various unary
  423. /// floating point operations. These are inspired by libm.
  424. FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
  425. FLOG, FLOG2, FLOG10, FEXP, FEXP2,
  426. FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR,
  427. FMINNUM, FMAXNUM,
  428. /// FSINCOS - Compute both fsin and fcos as a single operation.
  429. FSINCOS,
  430. /// LOAD and STORE have token chains as their first operand, then the same
  431. /// operands as an LLVM load/store instruction, then an offset node that
  432. /// is added / subtracted from the base pointer to form the address (for
  433. /// indexed memory ops).
  434. LOAD, STORE,
  435. /// DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
  436. /// to a specified boundary. This node always has two return values: a new
  437. /// stack pointer value and a chain. The first operand is the token chain,
  438. /// the second is the number of bytes to allocate, and the third is the
  439. /// alignment boundary. The size is guaranteed to be a multiple of the
  440. /// stack alignment, and the alignment is guaranteed to be bigger than the
  441. /// stack alignment (if required) or 0 to get standard stack alignment.
  442. DYNAMIC_STACKALLOC,
  443. /// Control flow instructions. These all have token chains.
  444. /// BR - Unconditional branch. The first operand is the chain
  445. /// operand, the second is the MBB to branch to.
  446. BR,
  447. /// BRIND - Indirect branch. The first operand is the chain, the second
  448. /// is the value to branch to, which must be of the same type as the
  449. /// target's pointer type.
  450. BRIND,
  451. /// BR_JT - Jumptable branch. The first operand is the chain, the second
  452. /// is the jumptable index, the last one is the jumptable entry index.
  453. BR_JT,
  454. /// BRCOND - Conditional branch. The first operand is the chain, the
  455. /// second is the condition, the third is the block to branch to if the
  456. /// condition is true. If the type of the condition is not i1, then the
  457. /// high bits must conform to getBooleanContents.
  458. BRCOND,
  459. /// BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in
  460. /// that the condition is represented as condition code, and two nodes to
  461. /// compare, rather than as a combined SetCC node. The operands in order
  462. /// are chain, cc, lhs, rhs, block to branch to if condition is true.
  463. BR_CC,
  464. /// INLINEASM - Represents an inline asm block. This node always has two
  465. /// return values: a chain and a flag result. The inputs are as follows:
  466. /// Operand #0 : Input chain.
  467. /// Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string.
  468. /// Operand #2 : a MDNodeSDNode with the !srcloc metadata.
  469. /// Operand #3 : HasSideEffect, IsAlignStack bits.
  470. /// After this, it is followed by a list of operands with this format:
  471. /// ConstantSDNode: Flags that encode whether it is a mem or not, the
  472. /// of operands that follow, etc. See InlineAsm.h.
  473. /// ... however many operands ...
  474. /// Operand #last: Optional, an incoming flag.
  475. ///
  476. /// The variable width operands are required to represent target addressing
  477. /// modes as a single "operand", even though they may have multiple
  478. /// SDOperands.
  479. INLINEASM,
  480. /// EH_LABEL - Represents a label in mid basic block used to track
  481. /// locations needed for debug and exception handling tables. These nodes
  482. /// take a chain as input and return a chain.
  483. EH_LABEL,
  484. /// STACKSAVE - STACKSAVE has one operand, an input chain. It produces a
  485. /// value, the same type as the pointer type for the system, and an output
  486. /// chain.
  487. STACKSAVE,
  488. /// STACKRESTORE has two operands, an input chain and a pointer to restore
  489. /// to it returns an output chain.
  490. STACKRESTORE,
  491. /// CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end
  492. /// of a call sequence, and carry arbitrary information that target might
  493. /// want to know. The first operand is a chain, the rest are specified by
  494. /// the target and not touched by the DAG optimizers.
  495. /// CALLSEQ_START..CALLSEQ_END pairs may not be nested.
  496. CALLSEQ_START, // Beginning of a call sequence
  497. CALLSEQ_END, // End of a call sequence
  498. /// VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE,
  499. /// and the alignment. It returns a pair of values: the vaarg value and a
  500. /// new chain.
  501. VAARG,
  502. /// VACOPY - VACOPY has 5 operands: an input chain, a destination pointer,
  503. /// a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
  504. /// source.
  505. VACOPY,
  506. /// VAEND, VASTART - VAEND and VASTART have three operands: an input chain,
  507. /// pointer, and a SRCVALUE.
  508. VAEND, VASTART,
  509. /// SRCVALUE - This is a node type that holds a Value* that is used to
  510. /// make reference to a value in the LLVM IR.
  511. SRCVALUE,
  512. /// MDNODE_SDNODE - This is a node that holdes an MDNode*, which is used to
  513. /// reference metadata in the IR.
  514. MDNODE_SDNODE,
  515. /// PCMARKER - This corresponds to the pcmarker intrinsic.
  516. PCMARKER,
  517. /// READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
  518. /// The only operand is a chain and a value and a chain are produced. The
  519. /// value is the contents of the architecture specific cycle counter like
  520. /// register (or other high accuracy low latency clock source)
  521. READCYCLECOUNTER,
  522. /// HANDLENODE node - Used as a handle for various purposes.
  523. HANDLENODE,
  524. /// INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic. It
  525. /// takes as input a token chain, the pointer to the trampoline, the pointer
  526. /// to the nested function, the pointer to pass for the 'nest' parameter, a
  527. /// SRCVALUE for the trampoline and another for the nested function
  528. /// (allowing targets to access the original Function*).
  529. /// It produces a token chain as output.
  530. INIT_TRAMPOLINE,
  531. /// ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
  532. /// It takes a pointer to the trampoline and produces a (possibly) new
  533. /// pointer to the same trampoline with platform-specific adjustments
  534. /// applied. The pointer it returns points to an executable block of code.
  535. ADJUST_TRAMPOLINE,
  536. /// TRAP - Trapping instruction
  537. TRAP,
  538. /// DEBUGTRAP - Trap intended to get the attention of a debugger.
  539. DEBUGTRAP,
  540. /// PREFETCH - This corresponds to a prefetch intrinsic. The first operand
  541. /// is the chain. The other operands are the address to prefetch,
  542. /// read / write specifier, locality specifier and instruction / data cache
  543. /// specifier.
  544. PREFETCH,
  545. /// OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope)
  546. /// This corresponds to the fence instruction. It takes an input chain, and
  547. /// two integer constants: an AtomicOrdering and a SynchronizationScope.
  548. ATOMIC_FENCE,
  549. /// Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr)
  550. /// This corresponds to "load atomic" instruction.
  551. ATOMIC_LOAD,
  552. /// OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val)
  553. /// This corresponds to "store atomic" instruction.
  554. ATOMIC_STORE,
  555. /// Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap)
  556. /// For double-word atomic operations:
  557. /// ValLo, ValHi, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmpLo, cmpHi,
  558. /// swapLo, swapHi)
  559. /// This corresponds to the cmpxchg instruction.
  560. ATOMIC_CMP_SWAP,
  561. /// Val, Success, OUTCHAIN
  562. /// = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap)
  563. /// N.b. this is still a strong cmpxchg operation, so
  564. /// Success == "Val == cmp".
  565. ATOMIC_CMP_SWAP_WITH_SUCCESS,
  566. /// Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt)
  567. /// Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt)
  568. /// For double-word atomic operations:
  569. /// ValLo, ValHi, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amtLo, amtHi)
  570. /// ValLo, ValHi, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amtLo, amtHi)
  571. /// These correspond to the atomicrmw instruction.
  572. ATOMIC_SWAP,
  573. ATOMIC_LOAD_ADD,
  574. ATOMIC_LOAD_SUB,
  575. ATOMIC_LOAD_AND,
  576. ATOMIC_LOAD_OR,
  577. ATOMIC_LOAD_XOR,
  578. ATOMIC_LOAD_NAND,
  579. ATOMIC_LOAD_MIN,
  580. ATOMIC_LOAD_MAX,
  581. ATOMIC_LOAD_UMIN,
  582. ATOMIC_LOAD_UMAX,
  583. // Masked load and store - consecutive vector load and store operations
  584. // with additional mask operand that prevents memory accesses to the
  585. // masked-off lanes.
  586. MLOAD, MSTORE,
  587. // Masked gather and scatter - load and store operations for a vector of
  588. // random addresses with additional mask operand that prevents memory
  589. // accesses to the masked-off lanes.
  590. MGATHER, MSCATTER,
  591. /// This corresponds to the llvm.lifetime.* intrinsics. The first operand
  592. /// is the chain and the second operand is the alloca pointer.
  593. LIFETIME_START, LIFETIME_END,
  594. /// GC_TRANSITION_START/GC_TRANSITION_END - These operators mark the
  595. /// beginning and end of GC transition sequence, and carry arbitrary
  596. /// information that target might need for lowering. The first operand is
  597. /// a chain, the rest are specified by the target and not touched by the DAG
  598. /// optimizers. GC_TRANSITION_START..GC_TRANSITION_END pairs may not be
  599. /// nested.
  600. GC_TRANSITION_START,
  601. GC_TRANSITION_END,
  602. /// BUILTIN_OP_END - This must be the last enum value in this list.
  603. /// The target-specific pre-isel opcode values start here.
  604. BUILTIN_OP_END
  605. };
  606. /// FIRST_TARGET_MEMORY_OPCODE - Target-specific pre-isel operations
  607. /// which do not reference a specific memory location should be less than
  608. /// this value. Those that do must not be less than this value, and can
  609. /// be used with SelectionDAG::getMemIntrinsicNode.
  610. static const int FIRST_TARGET_MEMORY_OPCODE = BUILTIN_OP_END+300;
  611. //===--------------------------------------------------------------------===//
  612. /// MemIndexedMode enum - This enum defines the load / store indexed
  613. /// addressing modes.
  614. ///
  615. /// UNINDEXED "Normal" load / store. The effective address is already
  616. /// computed and is available in the base pointer. The offset
  617. /// operand is always undefined. In addition to producing a
  618. /// chain, an unindexed load produces one value (result of the
  619. /// load); an unindexed store does not produce a value.
  620. ///
  621. /// PRE_INC Similar to the unindexed mode where the effective address is
  622. /// PRE_DEC the value of the base pointer add / subtract the offset.
  623. /// It considers the computation as being folded into the load /
  624. /// store operation (i.e. the load / store does the address
  625. /// computation as well as performing the memory transaction).
  626. /// The base operand is always undefined. In addition to
  627. /// producing a chain, pre-indexed load produces two values
  628. /// (result of the load and the result of the address
  629. /// computation); a pre-indexed store produces one value (result
  630. /// of the address computation).
  631. ///
  632. /// POST_INC The effective address is the value of the base pointer. The
  633. /// POST_DEC value of the offset operand is then added to / subtracted
  634. /// from the base after memory transaction. In addition to
  635. /// producing a chain, post-indexed load produces two values
  636. /// (the result of the load and the result of the base +/- offset
  637. /// computation); a post-indexed store produces one value (the
  638. /// the result of the base +/- offset computation).
  639. enum MemIndexedMode {
  640. UNINDEXED = 0,
  641. PRE_INC,
  642. PRE_DEC,
  643. POST_INC,
  644. POST_DEC,
  645. LAST_INDEXED_MODE
  646. };
  647. //===--------------------------------------------------------------------===//
  648. /// LoadExtType enum - This enum defines the three variants of LOADEXT
  649. /// (load with extension).
  650. ///
  651. /// SEXTLOAD loads the integer operand and sign extends it to a larger
  652. /// integer result type.
  653. /// ZEXTLOAD loads the integer operand and zero extends it to a larger
  654. /// integer result type.
  655. /// EXTLOAD is used for two things: floating point extending loads and
  656. /// integer extending loads [the top bits are undefined].
  657. enum LoadExtType {
  658. NON_EXTLOAD = 0,
  659. EXTLOAD,
  660. SEXTLOAD,
  661. ZEXTLOAD,
  662. LAST_LOADEXT_TYPE
  663. };
  664. NodeType getExtForLoadExtType(bool IsFP, LoadExtType);
  665. //===--------------------------------------------------------------------===//
  666. /// ISD::CondCode enum - These are ordered carefully to make the bitfields
  667. /// below work out, when considering SETFALSE (something that never exists
  668. /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered
  669. /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
  670. /// to. If the "N" column is 1, the result of the comparison is undefined if
  671. /// the input is a NAN.
  672. ///
  673. /// All of these (except for the 'always folded ops') should be handled for
  674. /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
  675. /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
  676. ///
  677. /// Note that these are laid out in a specific order to allow bit-twiddling
  678. /// to transform conditions.
  679. enum CondCode {
  680. // Opcode N U L G E Intuitive operation
  681. SETFALSE, // 0 0 0 0 Always false (always folded)
  682. SETOEQ, // 0 0 0 1 True if ordered and equal
  683. SETOGT, // 0 0 1 0 True if ordered and greater than
  684. SETOGE, // 0 0 1 1 True if ordered and greater than or equal
  685. SETOLT, // 0 1 0 0 True if ordered and less than
  686. SETOLE, // 0 1 0 1 True if ordered and less than or equal
  687. SETONE, // 0 1 1 0 True if ordered and operands are unequal
  688. SETO, // 0 1 1 1 True if ordered (no nans)
  689. SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y)
  690. SETUEQ, // 1 0 0 1 True if unordered or equal
  691. SETUGT, // 1 0 1 0 True if unordered or greater than
  692. SETUGE, // 1 0 1 1 True if unordered, greater than, or equal
  693. SETULT, // 1 1 0 0 True if unordered or less than
  694. SETULE, // 1 1 0 1 True if unordered, less than, or equal
  695. SETUNE, // 1 1 1 0 True if unordered or not equal
  696. SETTRUE, // 1 1 1 1 Always true (always folded)
  697. // Don't care operations: undefined if the input is a nan.
  698. SETFALSE2, // 1 X 0 0 0 Always false (always folded)
  699. SETEQ, // 1 X 0 0 1 True if equal
  700. SETGT, // 1 X 0 1 0 True if greater than
  701. SETGE, // 1 X 0 1 1 True if greater than or equal
  702. SETLT, // 1 X 1 0 0 True if less than
  703. SETLE, // 1 X 1 0 1 True if less than or equal
  704. SETNE, // 1 X 1 1 0 True if not equal
  705. SETTRUE2, // 1 X 1 1 1 Always true (always folded)
  706. SETCC_INVALID // Marker value.
  707. };
  708. /// isSignedIntSetCC - Return true if this is a setcc instruction that
  709. /// performs a signed comparison when used with integer operands.
  710. inline bool isSignedIntSetCC(CondCode Code) {
  711. return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
  712. }
  713. /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
  714. /// performs an unsigned comparison when used with integer operands.
  715. inline bool isUnsignedIntSetCC(CondCode Code) {
  716. return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
  717. }
  718. /// isTrueWhenEqual - Return true if the specified condition returns true if
  719. /// the two operands to the condition are equal. Note that if one of the two
  720. /// operands is a NaN, this value is meaningless.
  721. inline bool isTrueWhenEqual(CondCode Cond) {
  722. return ((int)Cond & 1) != 0;
  723. }
  724. /// getUnorderedFlavor - This function returns 0 if the condition is always
  725. /// false if an operand is a NaN, 1 if the condition is always true if the
  726. /// operand is a NaN, and 2 if the condition is undefined if the operand is a
  727. /// NaN.
  728. inline unsigned getUnorderedFlavor(CondCode Cond) {
  729. return ((int)Cond >> 3) & 3;
  730. }
  731. /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
  732. /// 'op' is a valid SetCC operation.
  733. CondCode getSetCCInverse(CondCode Operation, bool isInteger);
  734. /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
  735. /// when given the operation for (X op Y).
  736. CondCode getSetCCSwappedOperands(CondCode Operation);
  737. /// getSetCCOrOperation - Return the result of a logical OR between different
  738. /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This
  739. /// function returns SETCC_INVALID if it is not possible to represent the
  740. /// resultant comparison.
  741. CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
  742. /// getSetCCAndOperation - Return the result of a logical AND between
  743. /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This
  744. /// function returns SETCC_INVALID if it is not possible to represent the
  745. /// resultant comparison.
  746. CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
  747. //===--------------------------------------------------------------------===//
  748. /// CvtCode enum - This enum defines the various converts CONVERT_RNDSAT
  749. /// supports.
  750. enum CvtCode {
  751. CVT_FF, /// Float from Float
  752. CVT_FS, /// Float from Signed
  753. CVT_FU, /// Float from Unsigned
  754. CVT_SF, /// Signed from Float
  755. CVT_UF, /// Unsigned from Float
  756. CVT_SS, /// Signed from Signed
  757. CVT_SU, /// Signed from Unsigned
  758. CVT_US, /// Unsigned from Signed
  759. CVT_UU, /// Unsigned from Unsigned
  760. CVT_INVALID /// Marker - Invalid opcode
  761. };
  762. } // end llvm::ISD namespace
  763. } // end llvm namespace
  764. #endif