Instruction.def 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. //===-- llvm/Instruction.def - File that describes Instructions -*- 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 contains descriptions of the various LLVM instructions. This is
  10. // used as a central place for enumerating the different instructions and
  11. // should eventually be the place to put comments about the instructions.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. // NOTE: NO INCLUDE GUARD DESIRED!
  15. // Provide definitions of macros so that users of this file do not have to
  16. // define everything to use it...
  17. //
  18. #ifndef FIRST_TERM_INST
  19. #define FIRST_TERM_INST(num)
  20. #endif
  21. #ifndef HANDLE_TERM_INST
  22. #ifndef HANDLE_INST
  23. #define HANDLE_TERM_INST(num, opcode, Class)
  24. #else
  25. #define HANDLE_TERM_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
  26. #endif
  27. #endif
  28. #ifndef LAST_TERM_INST
  29. #define LAST_TERM_INST(num)
  30. #endif
  31. #ifndef FIRST_UNARY_INST
  32. #define FIRST_UNARY_INST(num)
  33. #endif
  34. #ifndef HANDLE_UNARY_INST
  35. #ifndef HANDLE_INST
  36. #define HANDLE_UNARY_INST(num, opcode, instclass)
  37. #else
  38. #define HANDLE_UNARY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
  39. #endif
  40. #endif
  41. #ifndef LAST_UNARY_INST
  42. #define LAST_UNARY_INST(num)
  43. #endif
  44. #ifndef FIRST_BINARY_INST
  45. #define FIRST_BINARY_INST(num)
  46. #endif
  47. #ifndef HANDLE_BINARY_INST
  48. #ifndef HANDLE_INST
  49. #define HANDLE_BINARY_INST(num, opcode, instclass)
  50. #else
  51. #define HANDLE_BINARY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
  52. #endif
  53. #endif
  54. #ifndef LAST_BINARY_INST
  55. #define LAST_BINARY_INST(num)
  56. #endif
  57. #ifndef FIRST_MEMORY_INST
  58. #define FIRST_MEMORY_INST(num)
  59. #endif
  60. #ifndef HANDLE_MEMORY_INST
  61. #ifndef HANDLE_INST
  62. #define HANDLE_MEMORY_INST(num, opcode, Class)
  63. #else
  64. #define HANDLE_MEMORY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
  65. #endif
  66. #endif
  67. #ifndef LAST_MEMORY_INST
  68. #define LAST_MEMORY_INST(num)
  69. #endif
  70. #ifndef FIRST_CAST_INST
  71. #define FIRST_CAST_INST(num)
  72. #endif
  73. #ifndef HANDLE_CAST_INST
  74. #ifndef HANDLE_INST
  75. #define HANDLE_CAST_INST(num, opcode, Class)
  76. #else
  77. #define HANDLE_CAST_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
  78. #endif
  79. #endif
  80. #ifndef LAST_CAST_INST
  81. #define LAST_CAST_INST(num)
  82. #endif
  83. #ifndef FIRST_FUNCLETPAD_INST
  84. #define FIRST_FUNCLETPAD_INST(num)
  85. #endif
  86. #ifndef HANDLE_FUNCLETPAD_INST
  87. #ifndef HANDLE_INST
  88. #define HANDLE_FUNCLETPAD_INST(num, opcode, Class)
  89. #else
  90. #define HANDLE_FUNCLETPAD_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
  91. #endif
  92. #endif
  93. #ifndef LAST_FUNCLETPAD_INST
  94. #define LAST_FUNCLETPAD_INST(num)
  95. #endif
  96. #ifndef FIRST_OTHER_INST
  97. #define FIRST_OTHER_INST(num)
  98. #endif
  99. #ifndef HANDLE_OTHER_INST
  100. #ifndef HANDLE_INST
  101. #define HANDLE_OTHER_INST(num, opcode, Class)
  102. #else
  103. #define HANDLE_OTHER_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
  104. #endif
  105. #endif
  106. #ifndef LAST_OTHER_INST
  107. #define LAST_OTHER_INST(num)
  108. #endif
  109. #ifndef HANDLE_USER_INST
  110. #define HANDLE_USER_INST(num, opc, Class) HANDLE_OTHER_INST(num, opc, Class)
  111. #endif
  112. // Terminator Instructions - These instructions are used to terminate a basic
  113. // block of the program. Every basic block must end with one of these
  114. // instructions for it to be a well formed basic block.
  115. //
  116. FIRST_TERM_INST ( 1)
  117. HANDLE_TERM_INST ( 1, Ret , ReturnInst)
  118. HANDLE_TERM_INST ( 2, Br , BranchInst)
  119. HANDLE_TERM_INST ( 3, Switch , SwitchInst)
  120. HANDLE_TERM_INST ( 4, IndirectBr , IndirectBrInst)
  121. HANDLE_TERM_INST ( 5, Invoke , InvokeInst)
  122. HANDLE_TERM_INST ( 6, Resume , ResumeInst)
  123. HANDLE_TERM_INST ( 7, Unreachable , UnreachableInst)
  124. HANDLE_TERM_INST ( 8, CleanupRet , CleanupReturnInst)
  125. HANDLE_TERM_INST ( 9, CatchRet , CatchReturnInst)
  126. HANDLE_TERM_INST (10, CatchSwitch , CatchSwitchInst)
  127. HANDLE_TERM_INST (11, CallBr , CallBrInst) // A call-site terminator
  128. LAST_TERM_INST (11)
  129. // Standard unary operators...
  130. FIRST_UNARY_INST(12)
  131. HANDLE_UNARY_INST(12, FNeg , UnaryOperator)
  132. LAST_UNARY_INST(12)
  133. // Standard binary operators...
  134. FIRST_BINARY_INST(13)
  135. HANDLE_BINARY_INST(13, Add , BinaryOperator)
  136. HANDLE_BINARY_INST(14, FAdd , BinaryOperator)
  137. HANDLE_BINARY_INST(15, Sub , BinaryOperator)
  138. HANDLE_BINARY_INST(16, FSub , BinaryOperator)
  139. HANDLE_BINARY_INST(17, Mul , BinaryOperator)
  140. HANDLE_BINARY_INST(18, FMul , BinaryOperator)
  141. HANDLE_BINARY_INST(19, UDiv , BinaryOperator)
  142. HANDLE_BINARY_INST(20, SDiv , BinaryOperator)
  143. HANDLE_BINARY_INST(21, FDiv , BinaryOperator)
  144. HANDLE_BINARY_INST(22, URem , BinaryOperator)
  145. HANDLE_BINARY_INST(23, SRem , BinaryOperator)
  146. HANDLE_BINARY_INST(24, FRem , BinaryOperator)
  147. // Logical operators (integer operands)
  148. HANDLE_BINARY_INST(25, Shl , BinaryOperator) // Shift left (logical)
  149. HANDLE_BINARY_INST(26, LShr , BinaryOperator) // Shift right (logical)
  150. HANDLE_BINARY_INST(27, AShr , BinaryOperator) // Shift right (arithmetic)
  151. HANDLE_BINARY_INST(28, And , BinaryOperator)
  152. HANDLE_BINARY_INST(29, Or , BinaryOperator)
  153. HANDLE_BINARY_INST(30, Xor , BinaryOperator)
  154. LAST_BINARY_INST(30)
  155. // Memory operators...
  156. FIRST_MEMORY_INST(31)
  157. HANDLE_MEMORY_INST(31, Alloca, AllocaInst) // Stack management
  158. HANDLE_MEMORY_INST(32, Load , LoadInst ) // Memory manipulation instrs
  159. HANDLE_MEMORY_INST(33, Store , StoreInst )
  160. HANDLE_MEMORY_INST(34, GetElementPtr, GetElementPtrInst)
  161. HANDLE_MEMORY_INST(35, Fence , FenceInst )
  162. HANDLE_MEMORY_INST(36, AtomicCmpXchg , AtomicCmpXchgInst )
  163. HANDLE_MEMORY_INST(37, AtomicRMW , AtomicRMWInst )
  164. LAST_MEMORY_INST(37)
  165. // Cast operators ...
  166. // NOTE: The order matters here because CastInst::isEliminableCastPair
  167. // NOTE: (see Instructions.cpp) encodes a table based on this ordering.
  168. FIRST_CAST_INST(38)
  169. HANDLE_CAST_INST(38, Trunc , TruncInst ) // Truncate integers
  170. HANDLE_CAST_INST(39, ZExt , ZExtInst ) // Zero extend integers
  171. HANDLE_CAST_INST(40, SExt , SExtInst ) // Sign extend integers
  172. HANDLE_CAST_INST(41, FPToUI , FPToUIInst ) // floating point -> UInt
  173. HANDLE_CAST_INST(42, FPToSI , FPToSIInst ) // floating point -> SInt
  174. HANDLE_CAST_INST(43, UIToFP , UIToFPInst ) // UInt -> floating point
  175. HANDLE_CAST_INST(44, SIToFP , SIToFPInst ) // SInt -> floating point
  176. HANDLE_CAST_INST(45, FPTrunc , FPTruncInst ) // Truncate floating point
  177. HANDLE_CAST_INST(46, FPExt , FPExtInst ) // Extend floating point
  178. HANDLE_CAST_INST(47, PtrToInt, PtrToIntInst) // Pointer -> Integer
  179. HANDLE_CAST_INST(48, IntToPtr, IntToPtrInst) // Integer -> Pointer
  180. HANDLE_CAST_INST(49, BitCast , BitCastInst ) // Type cast
  181. HANDLE_CAST_INST(50, AddrSpaceCast, AddrSpaceCastInst) // addrspace cast
  182. LAST_CAST_INST(50)
  183. FIRST_FUNCLETPAD_INST(51)
  184. HANDLE_FUNCLETPAD_INST(51, CleanupPad, CleanupPadInst)
  185. HANDLE_FUNCLETPAD_INST(52, CatchPad , CatchPadInst)
  186. LAST_FUNCLETPAD_INST(52)
  187. // Other operators...
  188. FIRST_OTHER_INST(53)
  189. HANDLE_OTHER_INST(53, ICmp , ICmpInst ) // Integer comparison instruction
  190. HANDLE_OTHER_INST(54, FCmp , FCmpInst ) // Floating point comparison instr.
  191. HANDLE_OTHER_INST(55, PHI , PHINode ) // PHI node instruction
  192. HANDLE_OTHER_INST(56, Call , CallInst ) // Call a function
  193. HANDLE_OTHER_INST(57, Select , SelectInst ) // select instruction
  194. HANDLE_USER_INST (58, UserOp1, Instruction) // May be used internally in a pass
  195. HANDLE_USER_INST (59, UserOp2, Instruction) // Internal to passes only
  196. HANDLE_OTHER_INST(60, VAArg , VAArgInst ) // vaarg instruction
  197. HANDLE_OTHER_INST(61, ExtractElement, ExtractElementInst)// extract from vector
  198. HANDLE_OTHER_INST(62, InsertElement, InsertElementInst) // insert into vector
  199. HANDLE_OTHER_INST(63, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
  200. HANDLE_OTHER_INST(64, ExtractValue, ExtractValueInst)// extract from aggregate
  201. HANDLE_OTHER_INST(65, InsertValue, InsertValueInst) // insert into aggregate
  202. HANDLE_OTHER_INST(66, LandingPad, LandingPadInst) // Landing pad instruction.
  203. HANDLE_OTHER_INST(67, Freeze, FreezeInst) // Freeze instruction.
  204. LAST_OTHER_INST(67)
  205. #undef FIRST_TERM_INST
  206. #undef HANDLE_TERM_INST
  207. #undef LAST_TERM_INST
  208. #undef FIRST_UNARY_INST
  209. #undef HANDLE_UNARY_INST
  210. #undef LAST_UNARY_INST
  211. #undef FIRST_BINARY_INST
  212. #undef HANDLE_BINARY_INST
  213. #undef LAST_BINARY_INST
  214. #undef FIRST_MEMORY_INST
  215. #undef HANDLE_MEMORY_INST
  216. #undef LAST_MEMORY_INST
  217. #undef FIRST_CAST_INST
  218. #undef HANDLE_CAST_INST
  219. #undef LAST_CAST_INST
  220. #undef FIRST_FUNCLETPAD_INST
  221. #undef HANDLE_FUNCLETPAD_INST
  222. #undef LAST_FUNCLETPAD_INST
  223. #undef FIRST_OTHER_INST
  224. #undef HANDLE_OTHER_INST
  225. #undef LAST_OTHER_INST
  226. #undef HANDLE_USER_INST
  227. #ifdef HANDLE_INST
  228. #undef HANDLE_INST
  229. #endif