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