1 //===- llvm/CallingConv.h - LLVM Calling Conventions ------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file defines LLVM's set of calling conventions. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_IR_CALLINGCONV_H 15 #define LLVM_IR_CALLINGCONV_H 16 17 namespace llvm { 18 19 /// CallingConv Namespace - This namespace contains an enum with a value for 20 /// the well-known calling conventions. 21 /// 22 namespace CallingConv { 23 24 /// LLVM IR allows to use arbitrary numbers as calling convention identifiers. 25 using ID = unsigned; 26 27 /// A set of enums which specify the assigned numeric values for known llvm 28 /// calling conventions. 29 /// LLVM Calling Convention Representation 30 enum { 31 /// C - The default llvm calling convention, compatible with C. This 32 /// convention is the only calling convention that supports varargs calls. 33 /// As with typical C calling conventions, the callee/caller have to 34 /// tolerate certain amounts of prototype mismatch. 35 C = 0, 36 37 // Generic LLVM calling conventions. None of these calling conventions 38 // support varargs calls, and all assume that the caller and callee 39 // prototype exactly match. 40 41 /// Fast - This calling convention attempts to make calls as fast as 42 /// possible (e.g. by passing things in registers). 43 Fast = 8, 44 45 // Cold - This calling convention attempts to make code in the caller as 46 // efficient as possible under the assumption that the call is not commonly 47 // executed. As such, these calls often preserve all registers so that the 48 // call does not break any live ranges in the caller side. 49 Cold = 9, 50 51 // GHC - Calling convention used by the Glasgow Haskell Compiler (GHC). 52 GHC = 10, 53 54 // HiPE - Calling convention used by the High-Performance Erlang Compiler 55 // (HiPE). 56 HiPE = 11, 57 58 // WebKit JS - Calling convention for stack based JavaScript calls 59 WebKit_JS = 12, 60 61 // AnyReg - Calling convention for dynamic register based calls (e.g. 62 // stackmap and patchpoint intrinsics). 63 AnyReg = 13, 64 65 // PreserveMost - Calling convention for runtime calls that preserves most 66 // registers. 67 PreserveMost = 14, 68 69 // PreserveAll - Calling convention for runtime calls that preserves 70 // (almost) all registers. 71 PreserveAll = 15, 72 73 // Swift - Calling convention for Swift. 74 Swift = 16, 75 76 // CXX_FAST_TLS - Calling convention for access functions. 77 CXX_FAST_TLS = 17, 78 79 // Target - This is the start of the target-specific calling conventions, 80 // e.g. fastcall and thiscall on X86. 81 FirstTargetCC = 64, 82 83 /// X86_StdCall - stdcall is the calling conventions mostly used by the 84 /// Win32 API. It is basically the same as the C convention with the 85 /// difference in that the callee is responsible for popping the arguments 86 /// from the stack. 87 X86_StdCall = 64, 88 89 /// X86_FastCall - 'fast' analog of X86_StdCall. Passes first two arguments 90 /// in ECX:EDX registers, others - via stack. Callee is responsible for 91 /// stack cleaning. 92 X86_FastCall = 65, 93 94 /// ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete, 95 /// but still used on some targets). 96 ARM_APCS = 66, 97 98 /// ARM_AAPCS - ARM Architecture Procedure Calling Standard calling 99 /// convention (aka EABI). Soft float variant. 100 ARM_AAPCS = 67, 101 102 /// ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI. 103 ARM_AAPCS_VFP = 68, 104 105 /// MSP430_INTR - Calling convention used for MSP430 interrupt routines. 106 MSP430_INTR = 69, 107 108 /// X86_ThisCall - Similar to X86_StdCall. Passes first argument in ECX, 109 /// others via stack. Callee is responsible for stack cleaning. MSVC uses 110 /// this by default for methods in its ABI. 111 X86_ThisCall = 70, 112 113 /// PTX_Kernel - Call to a PTX kernel. 114 /// Passes all arguments in parameter space. 115 PTX_Kernel = 71, 116 117 /// PTX_Device - Call to a PTX device function. 118 /// Passes all arguments in register or parameter space. 119 PTX_Device = 72, 120 121 /// SPIR_FUNC - Calling convention for SPIR non-kernel device functions. 122 /// No lowering or expansion of arguments. 123 /// Structures are passed as a pointer to a struct with the byval attribute. 124 /// Functions can only call SPIR_FUNC and SPIR_KERNEL functions. 125 /// Functions can only have zero or one return values. 126 /// Variable arguments are not allowed, except for printf. 127 /// How arguments/return values are lowered are not specified. 128 /// Functions are only visible to the devices. 129 SPIR_FUNC = 75, 130 131 /// SPIR_KERNEL - Calling convention for SPIR kernel functions. 132 /// Inherits the restrictions of SPIR_FUNC, except 133 /// Cannot have non-void return values. 134 /// Cannot have variable arguments. 135 /// Can also be called by the host. 136 /// Is externally visible. 137 SPIR_KERNEL = 76, 138 139 /// Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins 140 Intel_OCL_BI = 77, 141 142 /// The C convention as specified in the x86-64 supplement to the 143 /// System V ABI, used on most non-Windows systems. 144 X86_64_SysV = 78, 145 146 /// The C convention as implemented on Windows/x86-64 and 147 /// AArch64. This convention differs from the more common 148 /// \c X86_64_SysV convention in a number of ways, most notably in 149 /// that XMM registers used to pass arguments are shadowed by GPRs, 150 /// and vice versa. 151 /// On AArch64, this is identical to the normal C (AAPCS) calling 152 /// convention for normal functions, but floats are passed in integer 153 /// registers to variadic functions. 154 Win64 = 79, 155 156 /// MSVC calling convention that passes vectors and vector aggregates 157 /// in SSE registers. 158 X86_VectorCall = 80, 159 160 /// Calling convention used by HipHop Virtual Machine (HHVM) to 161 /// perform calls to and from translation cache, and for calling PHP 162 /// functions. 163 /// HHVM calling convention supports tail/sibling call elimination. 164 HHVM = 81, 165 166 /// HHVM calling convention for invoking C/C++ helpers. 167 HHVM_C = 82, 168 169 /// X86_INTR - x86 hardware interrupt context. Callee may take one or two 170 /// parameters, where the 1st represents a pointer to hardware context frame 171 /// and the 2nd represents hardware error code, the presence of the later 172 /// depends on the interrupt vector taken. Valid for both 32- and 64-bit 173 /// subtargets. 174 X86_INTR = 83, 175 176 /// Used for AVR interrupt routines. 177 AVR_INTR = 84, 178 179 /// Calling convention used for AVR signal routines. 180 AVR_SIGNAL = 85, 181 182 /// Calling convention used for special AVR rtlib functions 183 /// which have an "optimized" convention to preserve registers. 184 AVR_BUILTIN = 86, 185 186 /// Calling convention used for Mesa vertex shaders, or AMDPAL last shader 187 /// stage before rasterization (vertex shader if tessellation and geometry 188 /// are not in use, or otherwise copy shader if one is needed). 189 AMDGPU_VS = 87, 190 191 /// Calling convention used for Mesa/AMDPAL geometry shaders. 192 AMDGPU_GS = 88, 193 194 /// Calling convention used for Mesa/AMDPAL pixel shaders. 195 AMDGPU_PS = 89, 196 197 /// Calling convention used for Mesa/AMDPAL compute shaders. 198 AMDGPU_CS = 90, 199 200 /// Calling convention for AMDGPU code object kernels. 201 AMDGPU_KERNEL = 91, 202 203 /// Register calling convention used for parameters transfer optimization 204 X86_RegCall = 92, 205 206 /// Calling convention used for Mesa/AMDPAL hull shaders (= tessellation 207 /// control shaders). 208 AMDGPU_HS = 93, 209 210 /// Calling convention used for special MSP430 rtlib functions 211 /// which have an "optimized" convention using additional registers. 212 MSP430_BUILTIN = 94, 213 214 /// Calling convention used for AMDPAL vertex shader if tessellation is in 215 /// use. 216 AMDGPU_LS = 95, 217 218 /// Calling convention used for AMDPAL shader stage before geometry shader 219 /// if geometry is in use. So either the domain (= tessellation evaluation) 220 /// shader if tessellation is in use, or otherwise the vertex shader. 221 AMDGPU_ES = 96, 222 223 /// The highest possible calling convention ID. Must be some 2^k - 1. 224 MaxID = 1023 225 }; 226 227 } // end namespace CallingConv 228 229 } // end namespace llvm 230 231 #endif // LLVM_IR_CALLINGCONV_H 232