1
1
import cllvm
2
2
3
+ /// Enumerates the calling conventions supported by LLVM.
4
+ ///
5
+ /// The raw values of this enumeration *must* match those in
6
+ /// [llvm-c/Core.h](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Core.h)
7
+ public enum CallingConvention : UInt32 {
8
+ /// The default LLVM calling convention, compatible with C.
9
+ case c = 0
10
+ /// This calling convention attempts to make calls as fast as possible
11
+ /// (e.g. by passing things in registers).
12
+ case fast = 8
13
+ /// This calling convention attempts to make code in the caller as efficient
14
+ /// as possible under the assumption that the call is not commonly executed.
15
+ /// As such, these calls often preserve all registers so that the call does
16
+ /// not break any live ranges in the caller side.
17
+ case cold = 9
18
+ /// Calling convention for stack based JavaScript calls.
19
+ case webKitJS = 12
20
+ /// Calling convention for dynamic register based calls
21
+ /// (e.g. stackmap and patchpoint intrinsics).
22
+ case anyReg = 13
23
+ /// The calling conventions mostly used by the Win32 API.
24
+ ///
25
+ /// It is basically the same as the C convention with the difference in that
26
+ /// the callee is responsible for popping the arguments from the stack.
27
+ case x86Stdcall = 64
28
+ /// "Fast" analog of `x86Stdcall`.
29
+ ///
30
+ /// Passes first two arguments in ECX:EDX registers, others via the stack.
31
+ /// The callee is responsible for stack cleaning.
32
+ case x86Fastcall = 65
33
+ }
34
+
3
35
/// A `Function` represents a named function body in LLVM IR source. Functions
4
36
/// in LLVM IR encapsulate a list of parameters and a sequence of basic blocks
5
37
/// and provide a way to append to that sequence to build out its body.
@@ -9,6 +41,12 @@ public class Function: IRGlobal {
9
41
self . llvm = llvm
10
42
}
11
43
44
+ /// Accesses the calling convention for this function.
45
+ public var callingConvention : CallingConvention {
46
+ get { return CallingConvention ( rawValue: LLVMGetFunctionCallConv ( llvm) ) ! }
47
+ set { LLVMSetFunctionCallConv ( llvm, newValue. rawValue) }
48
+ }
49
+
12
50
/// Retrieves the entry block of this function.
13
51
///
14
52
/// The first basic block in a function is special in two ways: it is
0 commit comments