aboutsummaryrefslogtreecommitdiff
path: root/llvm/include/llvm/IR/CallingConv.h
blob: fd28542465225c0087dc009c12bb7aaa700fc9d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
//===- llvm/CallingConv.h - LLVM Calling Conventions ------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines LLVM's set of calling conventions.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_IR_CALLINGCONV_H
#define LLVM_IR_CALLINGCONV_H

namespace llvm {

/// CallingConv Namespace - This namespace contains an enum with a value for
/// the well-known calling conventions.
///
namespace CallingConv {

  /// LLVM IR allows to use arbitrary numbers as calling convention identifiers.
  using ID = unsigned;

  /// A set of enums which specify the assigned numeric values for known llvm
  /// calling conventions.
  /// LLVM Calling Convention Representation
  enum {
    /// C - The default llvm calling convention, compatible with C.  This
    /// convention is the only calling convention that supports varargs calls.
    /// As with typical C calling conventions, the callee/caller have to
    /// tolerate certain amounts of prototype mismatch.
    C = 0,

    // Generic LLVM calling conventions.  None of these calling conventions
    // support varargs calls, and all assume that the caller and callee
    // prototype exactly match.

    /// Fast - This calling convention attempts to make calls as fast as
    /// possible (e.g. by passing things in registers).
    Fast = 8,

    // Cold - This calling convention attempts to make code in the caller as
    // efficient as possible under the assumption that the call is not commonly
    // executed.  As such, these calls often preserve all registers so that the
    // call does not break any live ranges in the caller side.
    Cold = 9,

    // GHC - Calling convention used by the Glasgow Haskell Compiler (GHC).
    GHC = 10,

    // HiPE - Calling convention used by the High-Performance Erlang Compiler
    // (HiPE).
    HiPE = 11,

    // WebKit JS - Calling convention for stack based JavaScript calls
    WebKit_JS = 12,

    // AnyReg - Calling convention for dynamic register based calls (e.g.
    // stackmap and patchpoint intrinsics).
    AnyReg = 13,

    // PreserveMost - Calling convention for runtime calls that preserves most
    // registers.
    PreserveMost = 14,

    // PreserveAll - Calling convention for runtime calls that preserves
    // (almost) all registers.
    PreserveAll = 15,

    // Swift - Calling convention for Swift.
    Swift = 16,

    // CXX_FAST_TLS - Calling convention for access functions.
    CXX_FAST_TLS = 17,

    /// Tail - This calling convention attemps to make calls as fast as
    /// possible while guaranteeing that tail call optimization can always
    /// be performed.
    Tail = 18,

    /// Special calling convention on Windows for calling the Control
    /// Guard Check ICall funtion. The function takes exactly one argument
    /// (address of the target function) passed in the first argument register,
    /// and has no return value. All register values are preserved.
    CFGuard_Check = 19,

    /// SwiftTail - This follows the Swift calling convention in how arguments
    /// are passed but guarantees tail calls will be made by making the callee
    /// clean up their stack.
    SwiftTail = 20,

    // Target - This is the start of the target-specific calling conventions,
    // e.g. fastcall and thiscall on X86.
    FirstTargetCC = 64,

    /// X86_StdCall - stdcall is the calling conventions mostly used by the
    /// Win32 API. It is basically the same as the C convention with the
    /// difference in that the callee is responsible for popping the arguments
    /// from the stack.
    X86_StdCall = 64,

    /// X86_FastCall - 'fast' analog of X86_StdCall. Passes first two arguments
    /// in ECX:EDX registers, others - via stack. Callee is responsible for
    /// stack cleaning.
    X86_FastCall = 65,

    /// ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete,
    /// but still used on some targets).
    ARM_APCS = 66,

    /// ARM_AAPCS - ARM Architecture Procedure Calling Standard calling
    /// convention (aka EABI). Soft float variant.
    ARM_AAPCS = 67,

    /// ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
    ARM_AAPCS_VFP = 68,

    /// MSP430_INTR - Calling convention used for MSP430 interrupt routines.
    MSP430_INTR = 69,

    /// X86_ThisCall - Similar to X86_StdCall. Passes first argument in ECX,
    /// others via stack. Callee is responsible for stack cleaning. MSVC uses
    /// this by default for methods in its ABI.
    X86_ThisCall = 70,

    /// PTX_Kernel - Call to a PTX kernel.
    /// Passes all arguments in parameter space.
    PTX_Kernel = 71,

    /// PTX_Device - Call to a PTX device function.
    /// Passes all arguments in register or parameter space.
    PTX_Device = 72,

    /// SPIR_FUNC - Calling convention for SPIR non-kernel device functions.
    /// No lowering or expansion of arguments.
    /// Structures are passed as a pointer to a struct with the byval attribute.
    /// Functions can only call SPIR_FUNC and SPIR_KERNEL functions.
    /// Functions can only have zero or one return values.
    /// Variable arguments are not allowed, except for printf.
    /// How arguments/return values are lowered are not specified.
    /// Functions are only visible to the devices.
    SPIR_FUNC = 75,

    /// SPIR_KERNEL - Calling convention for SPIR kernel functions.
    /// Inherits the restrictions of SPIR_FUNC, except
    /// Cannot have non-void return values.
    /// Cannot have variable arguments.
    /// Can also be called by the host.
    /// Is externally visible.
    SPIR_KERNEL = 76,

    /// Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins
    Intel_OCL_BI = 77,

    /// The C convention as specified in the x86-64 supplement to the
    /// System V ABI, used on most non-Windows systems.
    X86_64_SysV = 78,

    /// The C convention as implemented on Windows/x86-64 and
    /// AArch64. This convention differs from the more common
    /// \c X86_64_SysV convention in a number of ways, most notably in
    /// that XMM registers used to pass arguments are shadowed by GPRs,
    /// and vice versa.
    /// On AArch64, this is identical to the normal C (AAPCS) calling
    /// convention for normal functions, but floats are passed in integer
    /// registers to variadic functions.
    Win64 = 79,

    /// MSVC calling convention that passes vectors and vector aggregates
    /// in SSE registers.
    X86_VectorCall = 80,

    /// Calling convention used by HipHop Virtual Machine (HHVM) to
    /// perform calls to and from translation cache, and for calling PHP
    /// functions.
    /// HHVM calling convention supports tail/sibling call elimination.
    HHVM = 81,

    /// HHVM calling convention for invoking C/C++ helpers.
    HHVM_C = 82,

    /// X86_INTR - x86 hardware interrupt context. Callee may take one or two
    /// parameters, where the 1st represents a pointer to hardware context frame
    /// and the 2nd represents hardware error code, the presence of the later
    /// depends on the interrupt vector taken. Valid for both 32- and 64-bit
    /// subtargets.
    X86_INTR = 83,

    /// Used for AVR interrupt routines.
    AVR_INTR = 84,

    /// Calling convention used for AVR signal routines.
    AVR_SIGNAL = 85,

    /// Calling convention used for special AVR rtlib functions
    /// which have an "optimized" convention to preserve registers.
    AVR_BUILTIN = 86,

    /// Calling convention used for Mesa vertex shaders, or AMDPAL last shader
    /// stage before rasterization (vertex shader if tessellation and geometry
    /// are not in use, or otherwise copy shader if one is needed).
    AMDGPU_VS = 87,

    /// Calling convention used for Mesa/AMDPAL geometry shaders.
    AMDGPU_GS = 88,

    /// Calling convention used for Mesa/AMDPAL pixel shaders.
    AMDGPU_PS = 89,

    /// Calling convention used for Mesa/AMDPAL compute shaders.
    AMDGPU_CS = 90,

    /// Calling convention for AMDGPU code object kernels.
    AMDGPU_KERNEL = 91,

    /// Register calling convention used for parameters transfer optimization
    X86_RegCall = 92,

    /// Calling convention used for Mesa/AMDPAL hull shaders (= tessellation
    /// control shaders).
    AMDGPU_HS = 93,

    /// Calling convention used for special MSP430 rtlib functions
    /// which have an "optimized" convention using additional registers.
    MSP430_BUILTIN = 94,

    /// Calling convention used for AMDPAL vertex shader if tessellation is in
    /// use.
    AMDGPU_LS = 95,

    /// Calling convention used for AMDPAL shader stage before geometry shader
    /// if geometry is in use. So either the domain (= tessellation evaluation)
    /// shader if tessellation is in use, or otherwise the vertex shader.
    AMDGPU_ES = 96,

    // Calling convention between AArch64 Advanced SIMD functions
    AArch64_VectorCall = 97,

    /// Calling convention between AArch64 SVE functions
    AArch64_SVE_VectorCall = 98,

    /// Calling convention for emscripten __invoke_* functions. The first
    /// argument is required to be the function ptr being indirectly called.
    /// The remainder matches the regular calling convention.
    WASM_EmscriptenInvoke = 99,

    /// Calling convention used for AMD graphics targets.
    AMDGPU_Gfx = 100,

    /// M68k_INTR - Calling convention used for M68k interrupt routines.
    M68k_INTR = 101,

    /// The highest possible calling convention ID. Must be some 2^k - 1.
    MaxID = 1023
  };

} // end namespace CallingConv

} // end namespace llvm

#endif // LLVM_IR_CALLINGCONV_H