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