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