CallingConv.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. //===- llvm/CallingConv.h - LLVM Calling Conventions ------------*- 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 defines LLVM's set of calling conventions.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_IR_CALLINGCONV_H
  13. #define LLVM_IR_CALLINGCONV_H
  14. namespace llvm {
  15. /// CallingConv Namespace - This namespace contains an enum with a value for
  16. /// the well-known calling conventions.
  17. ///
  18. namespace CallingConv {
  19. /// LLVM IR allows to use arbitrary numbers as calling convention identifiers.
  20. using ID = unsigned;
  21. /// A set of enums which specify the assigned numeric values for known llvm
  22. /// calling conventions.
  23. /// LLVM Calling Convention Representation
  24. enum {
  25. /// C - The default llvm calling convention, compatible with C. This
  26. /// convention is the only calling convention that supports varargs calls.
  27. /// As with typical C calling conventions, the callee/caller have to
  28. /// tolerate certain amounts of prototype mismatch.
  29. C = 0,
  30. // Generic LLVM calling conventions. None of these calling conventions
  31. // support varargs calls, and all assume that the caller and callee
  32. // prototype exactly match.
  33. /// Fast - This calling convention attempts to make calls as fast as
  34. /// possible (e.g. by passing things in registers).
  35. Fast = 8,
  36. // Cold - This calling convention attempts to make code in the caller as
  37. // efficient as possible under the assumption that the call is not commonly
  38. // executed. As such, these calls often preserve all registers so that the
  39. // call does not break any live ranges in the caller side.
  40. Cold = 9,
  41. // GHC - Calling convention used by the Glasgow Haskell Compiler (GHC).
  42. GHC = 10,
  43. // HiPE - Calling convention used by the High-Performance Erlang Compiler
  44. // (HiPE).
  45. HiPE = 11,
  46. // WebKit JS - Calling convention for stack based JavaScript calls
  47. WebKit_JS = 12,
  48. // AnyReg - Calling convention for dynamic register based calls (e.g.
  49. // stackmap and patchpoint intrinsics).
  50. AnyReg = 13,
  51. // PreserveMost - Calling convention for runtime calls that preserves most
  52. // registers.
  53. PreserveMost = 14,
  54. // PreserveAll - Calling convention for runtime calls that preserves
  55. // (almost) all registers.
  56. PreserveAll = 15,
  57. // Swift - Calling convention for Swift.
  58. Swift = 16,
  59. // CXX_FAST_TLS - Calling convention for access functions.
  60. CXX_FAST_TLS = 17,
  61. /// Tail - This calling convention attemps to make calls as fast as
  62. /// possible while guaranteeing that tail call optimization can always
  63. /// be performed.
  64. Tail = 18,
  65. /// Special calling convention on Windows for calling the Control
  66. /// Guard Check ICall funtion. The function takes exactly one argument
  67. /// (address of the target function) passed in the first argument register,
  68. /// and has no return value. All register values are preserved.
  69. CFGuard_Check = 19,
  70. /// SwiftTail - This follows the Swift calling convention in how arguments
  71. /// are passed but guarantees tail calls will be made by making the callee
  72. /// clean up their stack.
  73. SwiftTail = 20,
  74. // Target - This is the start of the target-specific calling conventions,
  75. // e.g. fastcall and thiscall on X86.
  76. FirstTargetCC = 64,
  77. /// X86_StdCall - stdcall is the calling conventions mostly used by the
  78. /// Win32 API. It is basically the same as the C convention with the
  79. /// difference in that the callee is responsible for popping the arguments
  80. /// from the stack.
  81. X86_StdCall = 64,
  82. /// X86_FastCall - 'fast' analog of X86_StdCall. Passes first two arguments
  83. /// in ECX:EDX registers, others - via stack. Callee is responsible for
  84. /// stack cleaning.
  85. X86_FastCall = 65,
  86. /// ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete,
  87. /// but still used on some targets).
  88. ARM_APCS = 66,
  89. /// ARM_AAPCS - ARM Architecture Procedure Calling Standard calling
  90. /// convention (aka EABI). Soft float variant.
  91. ARM_AAPCS = 67,
  92. /// ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
  93. ARM_AAPCS_VFP = 68,
  94. /// MSP430_INTR - Calling convention used for MSP430 interrupt routines.
  95. MSP430_INTR = 69,
  96. /// X86_ThisCall - Similar to X86_StdCall. Passes first argument in ECX,
  97. /// others via stack. Callee is responsible for stack cleaning. MSVC uses
  98. /// this by default for methods in its ABI.
  99. X86_ThisCall = 70,
  100. /// PTX_Kernel - Call to a PTX kernel.
  101. /// Passes all arguments in parameter space.
  102. PTX_Kernel = 71,
  103. /// PTX_Device - Call to a PTX device function.
  104. /// Passes all arguments in register or parameter space.
  105. PTX_Device = 72,
  106. /// SPIR_FUNC - Calling convention for SPIR non-kernel device functions.
  107. /// No lowering or expansion of arguments.
  108. /// Structures are passed as a pointer to a struct with the byval attribute.
  109. /// Functions can only call SPIR_FUNC and SPIR_KERNEL functions.
  110. /// Functions can only have zero or one return values.
  111. /// Variable arguments are not allowed, except for printf.
  112. /// How arguments/return values are lowered are not specified.
  113. /// Functions are only visible to the devices.
  114. SPIR_FUNC = 75,
  115. /// SPIR_KERNEL - Calling convention for SPIR kernel functions.
  116. /// Inherits the restrictions of SPIR_FUNC, except
  117. /// Cannot have non-void return values.
  118. /// Cannot have variable arguments.
  119. /// Can also be called by the host.
  120. /// Is externally visible.
  121. SPIR_KERNEL = 76,
  122. /// Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins
  123. Intel_OCL_BI = 77,
  124. /// The C convention as specified in the x86-64 supplement to the
  125. /// System V ABI, used on most non-Windows systems.
  126. X86_64_SysV = 78,
  127. /// The C convention as implemented on Windows/x86-64 and
  128. /// AArch64. This convention differs from the more common
  129. /// \c X86_64_SysV convention in a number of ways, most notably in
  130. /// that XMM registers used to pass arguments are shadowed by GPRs,
  131. /// and vice versa.
  132. /// On AArch64, this is identical to the normal C (AAPCS) calling
  133. /// convention for normal functions, but floats are passed in integer
  134. /// registers to variadic functions.
  135. Win64 = 79,
  136. /// MSVC calling convention that passes vectors and vector aggregates
  137. /// in SSE registers.
  138. X86_VectorCall = 80,
  139. /// Calling convention used by HipHop Virtual Machine (HHVM) to
  140. /// perform calls to and from translation cache, and for calling PHP
  141. /// functions.
  142. /// HHVM calling convention supports tail/sibling call elimination.
  143. HHVM = 81,
  144. /// HHVM calling convention for invoking C/C++ helpers.
  145. HHVM_C = 82,
  146. /// X86_INTR - x86 hardware interrupt context. Callee may take one or two
  147. /// parameters, where the 1st represents a pointer to hardware context frame
  148. /// and the 2nd represents hardware error code, the presence of the later
  149. /// depends on the interrupt vector taken. Valid for both 32- and 64-bit
  150. /// subtargets.
  151. X86_INTR = 83,
  152. /// Used for AVR interrupt routines.
  153. AVR_INTR = 84,
  154. /// Calling convention used for AVR signal routines.
  155. AVR_SIGNAL = 85,
  156. /// Calling convention used for special AVR rtlib functions
  157. /// which have an "optimized" convention to preserve registers.
  158. AVR_BUILTIN = 86,
  159. /// Calling convention used for Mesa vertex shaders, or AMDPAL last shader
  160. /// stage before rasterization (vertex shader if tessellation and geometry
  161. /// are not in use, or otherwise copy shader if one is needed).
  162. AMDGPU_VS = 87,
  163. /// Calling convention used for Mesa/AMDPAL geometry shaders.
  164. AMDGPU_GS = 88,
  165. /// Calling convention used for Mesa/AMDPAL pixel shaders.
  166. AMDGPU_PS = 89,
  167. /// Calling convention used for Mesa/AMDPAL compute shaders.
  168. AMDGPU_CS = 90,
  169. /// Calling convention for AMDGPU code object kernels.
  170. AMDGPU_KERNEL = 91,
  171. /// Register calling convention used for parameters transfer optimization
  172. X86_RegCall = 92,
  173. /// Calling convention used for Mesa/AMDPAL hull shaders (= tessellation
  174. /// control shaders).
  175. AMDGPU_HS = 93,
  176. /// Calling convention used for special MSP430 rtlib functions
  177. /// which have an "optimized" convention using additional registers.
  178. MSP430_BUILTIN = 94,
  179. /// Calling convention used for AMDPAL vertex shader if tessellation is in
  180. /// use.
  181. AMDGPU_LS = 95,
  182. /// Calling convention used for AMDPAL shader stage before geometry shader
  183. /// if geometry is in use. So either the domain (= tessellation evaluation)
  184. /// shader if tessellation is in use, or otherwise the vertex shader.
  185. AMDGPU_ES = 96,
  186. // Calling convention between AArch64 Advanced SIMD functions
  187. AArch64_VectorCall = 97,
  188. /// Calling convention between AArch64 SVE functions
  189. AArch64_SVE_VectorCall = 98,
  190. /// Calling convention for emscripten __invoke_* functions. The first
  191. /// argument is required to be the function ptr being indirectly called.
  192. /// The remainder matches the regular calling convention.
  193. WASM_EmscriptenInvoke = 99,
  194. /// Calling convention used for AMD graphics targets.
  195. AMDGPU_Gfx = 100,
  196. /// M68k_INTR - Calling convention used for M68k interrupt routines.
  197. M68k_INTR = 101,
  198. /// The highest possible calling convention ID. Must be some 2^k - 1.
  199. MaxID = 1023
  200. };
  201. } // end namespace CallingConv
  202. } // end namespace llvm
  203. #endif // LLVM_IR_CALLINGCONV_H