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