LLVM  mainline
CallingConv.h
Go to the documentation of this file.
00001 //===-- llvm/CallingConv.h - LLVM Calling Conventions -----------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines LLVM's set of calling conventions.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_IR_CALLINGCONV_H
00015 #define LLVM_IR_CALLINGCONV_H
00016 
00017 namespace llvm {
00018 
00019 /// CallingConv Namespace - This namespace contains an enum with a value for
00020 /// the well-known calling conventions.
00021 ///
00022 namespace CallingConv {
00023   /// LLVM IR allows to use arbitrary numbers as calling convention identifiers.
00024   typedef unsigned ID;
00025 
00026   /// A set of enums which specify the assigned numeric values for known llvm
00027   /// calling conventions.
00028   /// @brief LLVM Calling Convention Representation
00029   enum {
00030     /// C - The default llvm calling convention, compatible with C.  This
00031     /// convention is the only calling convention that supports varargs calls.
00032     /// As with typical C calling conventions, the callee/caller have to
00033     /// tolerate certain amounts of prototype mismatch.
00034     C = 0,
00035 
00036     // Generic LLVM calling conventions.  None of these calling conventions
00037     // support varargs calls, and all assume that the caller and callee
00038     // prototype exactly match.
00039 
00040     /// Fast - This calling convention attempts to make calls as fast as
00041     /// possible (e.g. by passing things in registers).
00042     Fast = 8,
00043 
00044     // Cold - This calling convention attempts to make code in the caller as
00045     // efficient as possible under the assumption that the call is not commonly
00046     // executed.  As such, these calls often preserve all registers so that the
00047     // call does not break any live ranges in the caller side.
00048     Cold = 9,
00049 
00050     // GHC - Calling convention used by the Glasgow Haskell Compiler (GHC).
00051     GHC = 10,
00052 
00053     // HiPE - Calling convention used by the High-Performance Erlang Compiler
00054     // (HiPE).
00055     HiPE = 11,
00056 
00057     // WebKit JS - Calling convention for stack based JavaScript calls
00058     WebKit_JS = 12,
00059 
00060     // AnyReg - Calling convention for dynamic register based calls (e.g.
00061     // stackmap and patchpoint intrinsics).
00062     AnyReg = 13,
00063 
00064     // PreserveMost - Calling convention for runtime calls that preserves most
00065     // registers.
00066     PreserveMost = 14,
00067 
00068     // PreserveAll - Calling convention for runtime calls that preserves
00069     // (almost) all registers.
00070     PreserveAll = 15,
00071 
00072     // Swift - Calling convention for Swift.
00073     Swift = 16,
00074 
00075     // CXX_FAST_TLS - Calling convention for access functions.
00076     CXX_FAST_TLS = 17,
00077 
00078     // Target - This is the start of the target-specific calling conventions,
00079     // e.g. fastcall and thiscall on X86.
00080     FirstTargetCC = 64,
00081 
00082     /// X86_StdCall - stdcall is the calling conventions mostly used by the
00083     /// Win32 API. It is basically the same as the C convention with the
00084     /// difference in that the callee is responsible for popping the arguments
00085     /// from the stack.
00086     X86_StdCall = 64,
00087 
00088     /// X86_FastCall - 'fast' analog of X86_StdCall. Passes first two arguments
00089     /// in ECX:EDX registers, others - via stack. Callee is responsible for
00090     /// stack cleaning.
00091     X86_FastCall = 65,
00092 
00093     /// ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete,
00094     /// but still used on some targets).
00095     ARM_APCS = 66,
00096 
00097     /// ARM_AAPCS - ARM Architecture Procedure Calling Standard calling
00098     /// convention (aka EABI). Soft float variant.
00099     ARM_AAPCS = 67,
00100 
00101     /// ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
00102     ARM_AAPCS_VFP = 68,
00103 
00104     /// MSP430_INTR - Calling convention used for MSP430 interrupt routines.
00105     MSP430_INTR = 69,
00106 
00107     /// X86_ThisCall - Similar to X86_StdCall. Passes first argument in ECX,
00108     /// others via stack. Callee is responsible for stack cleaning. MSVC uses
00109     /// this by default for methods in its ABI.
00110     X86_ThisCall = 70,
00111 
00112     /// PTX_Kernel - Call to a PTX kernel.
00113     /// Passes all arguments in parameter space.
00114     PTX_Kernel = 71,
00115 
00116     /// PTX_Device - Call to a PTX device function.
00117     /// Passes all arguments in register or parameter space.
00118     PTX_Device = 72,
00119 
00120     /// SPIR_FUNC - Calling convention for SPIR non-kernel device functions.
00121     /// No lowering or expansion of arguments.
00122     /// Structures are passed as a pointer to a struct with the byval attribute.
00123     /// Functions can only call SPIR_FUNC and SPIR_KERNEL functions.
00124     /// Functions can only have zero or one return values.
00125     /// Variable arguments are not allowed, except for printf.
00126     /// How arguments/return values are lowered are not specified.
00127     /// Functions are only visible to the devices.
00128     SPIR_FUNC = 75,
00129 
00130     /// SPIR_KERNEL - Calling convention for SPIR kernel functions.
00131     /// Inherits the restrictions of SPIR_FUNC, except
00132     /// Cannot have non-void return values.
00133     /// Cannot have variable arguments.
00134     /// Can also be called by the host.
00135     /// Is externally visible.
00136     SPIR_KERNEL = 76,
00137 
00138     /// Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins
00139     Intel_OCL_BI = 77,
00140 
00141     /// \brief The C convention as specified in the x86-64 supplement to the
00142     /// System V ABI, used on most non-Windows systems.
00143     X86_64_SysV = 78,
00144 
00145     /// \brief The C convention as implemented on Windows/x86-64. This
00146     /// convention differs from the more common \c X86_64_SysV convention
00147     /// in a number of ways, most notably in that XMM registers used to pass
00148     /// arguments are shadowed by GPRs, and vice versa.
00149     X86_64_Win64 = 79,
00150 
00151     /// \brief MSVC calling convention that passes vectors and vector aggregates
00152     /// in SSE registers.
00153     X86_VectorCall = 80,
00154 
00155     /// \brief Calling convention used by HipHop Virtual Machine (HHVM) to
00156     /// perform calls to and from translation cache, and for calling PHP
00157     /// functions.
00158     /// HHVM calling convention supports tail/sibling call elimination.
00159     HHVM = 81,
00160 
00161     /// \brief HHVM calling convention for invoking C/C++ helpers.
00162     HHVM_C = 82,
00163 
00164     /// X86_INTR - x86 hardware interrupt context. Callee may take one or two
00165     /// parameters, where the 1st represents a pointer to hardware context frame
00166     /// and the 2nd represents hardware error code, the presence of the later
00167     /// depends on the interrupt vector taken. Valid for both 32- and 64-bit
00168     /// subtargets.
00169     X86_INTR = 83,
00170 
00171     /// Used for AVR interrupt routines.
00172     AVR_INTR = 84,
00173 
00174     /// Calling convention used for AVR signal routines.
00175     AVR_SIGNAL = 85,
00176 
00177     /// Calling convention used for special AVR rtlib functions
00178     /// which have an "optimized" convention to preserve registers.
00179     AVR_BUILTIN = 86,
00180 
00181     /// The highest possible calling convention ID. Must be some 2^k - 1.
00182     MaxID = 1023
00183   };
00184 } // End CallingConv namespace
00185 
00186 } // End llvm namespace
00187 
00188 #endif