LLVM  10.0.0
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  // Target - This is the start of the target-specific calling conventions,
90  // e.g. fastcall and thiscall on X86.
92 
93  /// X86_StdCall - stdcall is the calling conventions mostly used by the
94  /// Win32 API. It is basically the same as the C convention with the
95  /// difference in that the callee is responsible for popping the arguments
96  /// from the stack.
98 
99  /// X86_FastCall - 'fast' analog of X86_StdCall. Passes first two arguments
100  /// in ECX:EDX registers, others - via stack. Callee is responsible for
101  /// stack cleaning.
103 
104  /// ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete,
105  /// but still used on some targets).
106  ARM_APCS = 66,
107 
108  /// ARM_AAPCS - ARM Architecture Procedure Calling Standard calling
109  /// convention (aka EABI). Soft float variant.
110  ARM_AAPCS = 67,
111 
112  /// ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
114 
115  /// MSP430_INTR - Calling convention used for MSP430 interrupt routines.
117 
118  /// X86_ThisCall - Similar to X86_StdCall. Passes first argument in ECX,
119  /// others via stack. Callee is responsible for stack cleaning. MSVC uses
120  /// this by default for methods in its ABI.
122 
123  /// PTX_Kernel - Call to a PTX kernel.
124  /// Passes all arguments in parameter space.
126 
127  /// PTX_Device - Call to a PTX device function.
128  /// Passes all arguments in register or parameter space.
130 
131  /// SPIR_FUNC - Calling convention for SPIR non-kernel device functions.
132  /// No lowering or expansion of arguments.
133  /// Structures are passed as a pointer to a struct with the byval attribute.
134  /// Functions can only call SPIR_FUNC and SPIR_KERNEL functions.
135  /// Functions can only have zero or one return values.
136  /// Variable arguments are not allowed, except for printf.
137  /// How arguments/return values are lowered are not specified.
138  /// Functions are only visible to the devices.
139  SPIR_FUNC = 75,
140 
141  /// SPIR_KERNEL - Calling convention for SPIR kernel functions.
142  /// Inherits the restrictions of SPIR_FUNC, except
143  /// Cannot have non-void return values.
144  /// Cannot have variable arguments.
145  /// Can also be called by the host.
146  /// Is externally visible.
148 
149  /// Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins
151 
152  /// The C convention as specified in the x86-64 supplement to the
153  /// System V ABI, used on most non-Windows systems.
155 
156  /// The C convention as implemented on Windows/x86-64 and
157  /// AArch64. This convention differs from the more common
158  /// \c X86_64_SysV convention in a number of ways, most notably in
159  /// that XMM registers used to pass arguments are shadowed by GPRs,
160  /// and vice versa.
161  /// On AArch64, this is identical to the normal C (AAPCS) calling
162  /// convention for normal functions, but floats are passed in integer
163  /// registers to variadic functions.
164  Win64 = 79,
165 
166  /// MSVC calling convention that passes vectors and vector aggregates
167  /// in SSE registers.
169 
170  /// Calling convention used by HipHop Virtual Machine (HHVM) to
171  /// perform calls to and from translation cache, and for calling PHP
172  /// functions.
173  /// HHVM calling convention supports tail/sibling call elimination.
174  HHVM = 81,
175 
176  /// HHVM calling convention for invoking C/C++ helpers.
177  HHVM_C = 82,
178 
179  /// X86_INTR - x86 hardware interrupt context. Callee may take one or two
180  /// parameters, where the 1st represents a pointer to hardware context frame
181  /// and the 2nd represents hardware error code, the presence of the later
182  /// depends on the interrupt vector taken. Valid for both 32- and 64-bit
183  /// subtargets.
184  X86_INTR = 83,
185 
186  /// Used for AVR interrupt routines.
187  AVR_INTR = 84,
188 
189  /// Calling convention used for AVR signal routines.
191 
192  /// Calling convention used for special AVR rtlib functions
193  /// which have an "optimized" convention to preserve registers.
195 
196  /// Calling convention used for Mesa vertex shaders, or AMDPAL last shader
197  /// stage before rasterization (vertex shader if tessellation and geometry
198  /// are not in use, or otherwise copy shader if one is needed).
199  AMDGPU_VS = 87,
200 
201  /// Calling convention used for Mesa/AMDPAL geometry shaders.
202  AMDGPU_GS = 88,
203 
204  /// Calling convention used for Mesa/AMDPAL pixel shaders.
205  AMDGPU_PS = 89,
206 
207  /// Calling convention used for Mesa/AMDPAL compute shaders.
208  AMDGPU_CS = 90,
209 
210  /// Calling convention for AMDGPU code object kernels.
212 
213  /// Register calling convention used for parameters transfer optimization
215 
216  /// Calling convention used for Mesa/AMDPAL hull shaders (= tessellation
217  /// control shaders).
218  AMDGPU_HS = 93,
219 
220  /// Calling convention used for special MSP430 rtlib functions
221  /// which have an "optimized" convention using additional registers.
223 
224  /// Calling convention used for AMDPAL vertex shader if tessellation is in
225  /// use.
226  AMDGPU_LS = 95,
227 
228  /// Calling convention used for AMDPAL shader stage before geometry shader
229  /// if geometry is in use. So either the domain (= tessellation evaluation)
230  /// shader if tessellation is in use, or otherwise the vertex shader.
231  AMDGPU_ES = 96,
232 
233  // Calling convention between AArch64 Advanced SIMD functions
235 
236  /// Calling convention between AArch64 SVE functions
238 
239  /// Calling convention for emscripten __invoke_* functions. The first
240  /// argument is required to be the function ptr being indirectly called.
241  /// The remainder matches the regular calling convention.
243 
244  /// The highest possible calling convention 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
MSVC calling convention that passes vectors and vector aggregates in SSE registers.
Definition: CallingConv.h:168
Calling convention used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
Definition: CallingConv.h:218
The C convention as specified in the x86-64 supplement to the System V ABI, used on most non-Windows ...
Definition: CallingConv.h:154
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Calling convention used by HipHop Virtual Machine (HHVM) to perform calls to and from translation cac...
Definition: CallingConv.h:174
C - The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
Calling convention used for AMDPAL vertex shader if tessellation is in use.
Definition: CallingConv.h:226
Calling convention between AArch64 SVE functions.
Definition: CallingConv.h:237
Calling convention used for Mesa/AMDPAL geometry shaders.
Definition: CallingConv.h:202
SPIR_KERNEL - Calling convention for SPIR kernel functions.
Definition: CallingConv.h:147
PTX_Kernel - Call to a PTX kernel.
Definition: CallingConv.h:125
Calling convention used for AVR signal routines.
Definition: CallingConv.h:190
Calling convention used for Mesa/AMDPAL compute shaders.
Definition: CallingConv.h:208
The C convention as implemented on Windows/x86-64 and AArch64.
Definition: CallingConv.h:164
X86_INTR - x86 hardware interrupt context.
Definition: CallingConv.h:184
Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins.
Definition: CallingConv.h:150
ARM_AAPCS - ARM Architecture Procedure Calling Standard calling convention (aka EABI).
Definition: CallingConv.h:110
MSP430_INTR - Calling convention used for MSP430 interrupt routines.
Definition: CallingConv.h:116
The highest possible calling convention ID. Must be some 2^k - 1.
Definition: CallingConv.h:245
PTX_Device - Call to a PTX device function.
Definition: CallingConv.h:129
Register calling convention used for parameters transfer optimization.
Definition: CallingConv.h:214
ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
Definition: CallingConv.h:113
ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete, but still used on some target...
Definition: CallingConv.h:106
Calling convention used for Mesa/AMDPAL pixel shaders.
Definition: CallingConv.h:205
X86_StdCall - stdcall is the calling conventions mostly used by the Win32 API.
Definition: CallingConv.h:97
Calling convention for emscripten __invoke_* functions.
Definition: CallingConv.h:242
X86_FastCall - 'fast' analog of X86_StdCall.
Definition: CallingConv.h:102
SPIR_FUNC - Calling convention for SPIR non-kernel device functions.
Definition: CallingConv.h:139
Calling convention used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (ve...
Definition: CallingConv.h:199
Tail - This calling convention attemps to make calls as fast as possible while guaranteeing that tail...
Definition: CallingConv.h:81
Calling convention used for special AVR rtlib functions which have an "optimized" convention to prese...
Definition: CallingConv.h:194
Calling convention used for special MSP430 rtlib functions which have an "optimized" convention using...
Definition: CallingConv.h:222
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
Definition: CallingConv.h:87
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:42
Calling convention for AMDGPU code object kernels.
Definition: CallingConv.h:211
Used for AVR interrupt routines.
Definition: CallingConv.h:187
HHVM calling convention for invoking C/C++ helpers.
Definition: CallingConv.h:177
X86_ThisCall - Similar to X86_StdCall.
Definition: CallingConv.h:121
Calling convention used for AMDPAL shader stage before geometry shader if geometry is in use...
Definition: CallingConv.h:231