1 //===- llvm/CallingConv.h - LLVM Calling Conventions ------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines LLVM's set of calling conventions.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_IR_CALLINGCONV_H
14 #define LLVM_IR_CALLINGCONV_H
18 /// CallingConv Namespace - This namespace contains an enum with a value for
19 /// the well-known calling conventions.
21 namespace CallingConv
{
23 /// LLVM IR allows to use arbitrary numbers as calling convention identifiers.
26 /// A set of enums which specify the assigned numeric values for known llvm
27 /// calling conventions.
28 /// LLVM Calling Convention Representation
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.
36 // Generic LLVM calling conventions. None of these calling conventions
37 // support varargs calls, and all assume that the caller and callee
38 // prototype exactly match.
40 /// Fast - This calling convention attempts to make calls as fast as
41 /// possible (e.g. by passing things in registers).
44 // Cold - This calling convention attempts to make code in the caller as
45 // efficient as possible under the assumption that the call is not commonly
46 // executed. As such, these calls often preserve all registers so that the
47 // call does not break any live ranges in the caller side.
50 // GHC - Calling convention used by the Glasgow Haskell Compiler (GHC).
53 // HiPE - Calling convention used by the High-Performance Erlang Compiler
57 // WebKit JS - Calling convention for stack based JavaScript calls
60 // AnyReg - Calling convention for dynamic register based calls (e.g.
61 // stackmap and patchpoint intrinsics).
64 // PreserveMost - Calling convention for runtime calls that preserves most
68 // PreserveAll - Calling convention for runtime calls that preserves
69 // (almost) all registers.
72 // Swift - Calling convention for Swift.
75 // CXX_FAST_TLS - Calling convention for access functions.
78 // Target - This is the start of the target-specific calling conventions,
79 // e.g. fastcall and thiscall on X86.
82 /// X86_StdCall - stdcall is the calling conventions mostly used by the
83 /// Win32 API. It is basically the same as the C convention with the
84 /// difference in that the callee is responsible for popping the arguments
88 /// X86_FastCall - 'fast' analog of X86_StdCall. Passes first two arguments
89 /// in ECX:EDX registers, others - via stack. Callee is responsible for
93 /// ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete,
94 /// but still used on some targets).
97 /// ARM_AAPCS - ARM Architecture Procedure Calling Standard calling
98 /// convention (aka EABI). Soft float variant.
101 /// ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
104 /// MSP430_INTR - Calling convention used for MSP430 interrupt routines.
107 /// X86_ThisCall - Similar to X86_StdCall. Passes first argument in ECX,
108 /// others via stack. Callee is responsible for stack cleaning. MSVC uses
109 /// this by default for methods in its ABI.
112 /// PTX_Kernel - Call to a PTX kernel.
113 /// Passes all arguments in parameter space.
116 /// PTX_Device - Call to a PTX device function.
117 /// Passes all arguments in register or parameter space.
120 /// SPIR_FUNC - Calling convention for SPIR non-kernel device functions.
121 /// No lowering or expansion of arguments.
122 /// Structures are passed as a pointer to a struct with the byval attribute.
123 /// Functions can only call SPIR_FUNC and SPIR_KERNEL functions.
124 /// Functions can only have zero or one return values.
125 /// Variable arguments are not allowed, except for printf.
126 /// How arguments/return values are lowered are not specified.
127 /// Functions are only visible to the devices.
130 /// SPIR_KERNEL - Calling convention for SPIR kernel functions.
131 /// Inherits the restrictions of SPIR_FUNC, except
132 /// Cannot have non-void return values.
133 /// Cannot have variable arguments.
134 /// Can also be called by the host.
135 /// Is externally visible.
138 /// Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins
141 /// The C convention as specified in the x86-64 supplement to the
142 /// System V ABI, used on most non-Windows systems.
145 /// The C convention as implemented on Windows/x86-64 and
146 /// AArch64. This convention differs from the more common
147 /// \c X86_64_SysV convention in a number of ways, most notably in
148 /// that XMM registers used to pass arguments are shadowed by GPRs,
150 /// On AArch64, this is identical to the normal C (AAPCS) calling
151 /// convention for normal functions, but floats are passed in integer
152 /// registers to variadic functions.
155 /// MSVC calling convention that passes vectors and vector aggregates
156 /// in SSE registers.
159 /// Calling convention used by HipHop Virtual Machine (HHVM) to
160 /// perform calls to and from translation cache, and for calling PHP
162 /// HHVM calling convention supports tail/sibling call elimination.
165 /// HHVM calling convention for invoking C/C++ helpers.
168 /// X86_INTR - x86 hardware interrupt context. Callee may take one or two
169 /// parameters, where the 1st represents a pointer to hardware context frame
170 /// and the 2nd represents hardware error code, the presence of the later
171 /// depends on the interrupt vector taken. Valid for both 32- and 64-bit
175 /// Used for AVR interrupt routines.
178 /// Calling convention used for AVR signal routines.
181 /// Calling convention used for special AVR rtlib functions
182 /// which have an "optimized" convention to preserve registers.
185 /// Calling convention used for Mesa vertex shaders, or AMDPAL last shader
186 /// stage before rasterization (vertex shader if tessellation and geometry
187 /// are not in use, or otherwise copy shader if one is needed).
190 /// Calling convention used for Mesa/AMDPAL geometry shaders.
193 /// Calling convention used for Mesa/AMDPAL pixel shaders.
196 /// Calling convention used for Mesa/AMDPAL compute shaders.
199 /// Calling convention for AMDGPU code object kernels.
202 /// Register calling convention used for parameters transfer optimization
205 /// Calling convention used for Mesa/AMDPAL hull shaders (= tessellation
206 /// control shaders).
209 /// Calling convention used for special MSP430 rtlib functions
210 /// which have an "optimized" convention using additional registers.
213 /// Calling convention used for AMDPAL vertex shader if tessellation is in
217 /// Calling convention used for AMDPAL shader stage before geometry shader
218 /// if geometry is in use. So either the domain (= tessellation evaluation)
219 /// shader if tessellation is in use, or otherwise the vertex shader.
222 // Calling convention between AArch64 Advanced SIMD functions
223 AArch64_VectorCall
= 97,
225 /// Calling convention between AArch64 SVE functions
226 AArch64_SVE_VectorCall
= 98,
228 /// Calling convention for emscripten __invoke_* functions. The first
229 /// argument is required to be the function ptr being indirectly called.
230 /// The remainder matches the regular calling convention.
231 WASM_EmscriptenInvoke
= 99,
233 /// The highest possible calling convention ID. Must be some 2^k - 1.
237 } // end namespace CallingConv
239 } // end namespace llvm
241 #endif // LLVM_IR_CALLINGCONV_H