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
17namespace llvm {
18
19/// CallingConv Namespace - This namespace contains an enum with a value for
20/// the well-known calling conventions.
21///
22namespace CallingConv {
23  /// A set of enums which specify the assigned numeric values for known llvm
24  /// calling conventions.
25  /// @brief LLVM Calling Convention Representation
26  enum ID {
27    /// C - The default llvm calling convention, compatible with C.  This
28    /// convention is the only calling convention that supports varargs calls.
29    /// As with typical C calling conventions, the callee/caller have to
30    /// tolerate certain amounts of prototype mismatch.
31    C = 0,
32
33    // Generic LLVM calling conventions.  None of these calling conventions
34    // support varargs calls, and all assume that the caller and callee
35    // prototype exactly match.
36
37    /// Fast - This calling convention attempts to make calls as fast as
38    /// possible (e.g. by passing things in registers).
39    Fast = 8,
40
41    // Cold - This calling convention attempts to make code in the caller as
42    // efficient as possible under the assumption that the call is not commonly
43    // executed.  As such, these calls often preserve all registers so that the
44    // call does not break any live ranges in the caller side.
45    Cold = 9,
46
47    // GHC - Calling convention used by the Glasgow Haskell Compiler (GHC).
48    GHC = 10,
49
50    // HiPE - Calling convention used by the High-Performance Erlang Compiler
51    // (HiPE).
52    HiPE = 11,
53
54    // WebKit JS - Calling convention for stack based JavaScript calls
55    WebKit_JS = 12,
56
57    // AnyReg - Calling convention for dynamic register based calls (e.g.
58    // stackmap and patchpoint intrinsics).
59    AnyReg = 13,
60
61    // PreserveMost - Calling convention for runtime calls that preserves most
62    // registers.
63    PreserveMost = 14,
64
65    // PreserveAll - Calling convention for runtime calls that preserves
66    // (almost) all registers.
67    PreserveAll = 15,
68
69    // Target - This is the start of the target-specific calling conventions,
70    // e.g. fastcall and thiscall on X86.
71    FirstTargetCC = 64,
72
73    /// X86_StdCall - stdcall is the calling conventions mostly used by the
74    /// Win32 API. It is basically the same as the C convention with the
75    /// difference in that the callee is responsible for popping the arguments
76    /// from the stack.
77    X86_StdCall = 64,
78
79    /// X86_FastCall - 'fast' analog of X86_StdCall. Passes first two arguments
80    /// in ECX:EDX registers, others - via stack. Callee is responsible for
81    /// stack cleaning.
82    X86_FastCall = 65,
83
84    /// ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete,
85    /// but still used on some targets).
86    ARM_APCS = 66,
87
88    /// ARM_AAPCS - ARM Architecture Procedure Calling Standard calling
89    /// convention (aka EABI). Soft float variant.
90    ARM_AAPCS = 67,
91
92    /// ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
93    ARM_AAPCS_VFP = 68,
94
95    /// MSP430_INTR - Calling convention used for MSP430 interrupt routines.
96    MSP430_INTR = 69,
97
98    /// X86_ThisCall - Similar to X86_StdCall. Passes first argument in ECX,
99    /// others via stack. Callee is responsible for stack cleaning. MSVC uses
100    /// this by default for methods in its ABI.
101    X86_ThisCall = 70,
102
103    /// PTX_Kernel - Call to a PTX kernel.
104    /// Passes all arguments in parameter space.
105    PTX_Kernel = 71,
106
107    /// PTX_Device - Call to a PTX device function.
108    /// Passes all arguments in register or parameter space.
109    PTX_Device = 72,
110
111    /// SPIR_FUNC - Calling convention for SPIR non-kernel device functions.
112    /// No lowering or expansion of arguments.
113    /// Structures are passed as a pointer to a struct with the byval attribute.
114    /// Functions can only call SPIR_FUNC and SPIR_KERNEL functions.
115    /// Functions can only have zero or one return values.
116    /// Variable arguments are not allowed, except for printf.
117    /// How arguments/return values are lowered are not specified.
118    /// Functions are only visible to the devices.
119    SPIR_FUNC = 75,
120
121    /// SPIR_KERNEL - Calling convention for SPIR kernel functions.
122    /// Inherits the restrictions of SPIR_FUNC, except
123    /// Cannot have non-void return values.
124    /// Cannot have variable arguments.
125    /// Can also be called by the host.
126    /// Is externally visible.
127    SPIR_KERNEL = 76,
128
129    /// Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins
130    Intel_OCL_BI = 77,
131
132    /// \brief The C convention as specified in the x86-64 supplement to the
133    /// System V ABI, used on most non-Windows systems.
134    X86_64_SysV = 78,
135
136    /// \brief The C convention as implemented on Windows/x86-64. This
137    /// convention differs from the more common \c X86_64_SysV convention
138    /// in a number of ways, most notably in that XMM registers used to pass
139    /// arguments are shadowed by GPRs, and vice versa.
140    X86_64_Win64 = 79
141  };
142} // End CallingConv namespace
143
144} // End llvm namespace
145
146#endif
147