CallingConv.h 9.0 KB

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