CallingConv.h 9.5 KB

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