Merge pull request #2603 from kumpera/fix_set_pending_exception
[mono.git] / mono / mini / mini-llvm-cpp.h
1 /*
2  * mini-llvm-cpp.h: LLVM backend
3  *
4  * Authors:
5  *   Zoltan Varga (vargaz@gmail.com)
6  *
7  * (C) 2009 Novell, Inc.
8  */
9
10 #ifndef __MONO_MINI_LLVM_CPP_H__
11 #define __MONO_MINI_LLVM_CPP_H__
12
13 #include <glib.h>
14
15 #include "llvm-c/Core.h"
16 #include "llvm-c/ExecutionEngine.h"
17
18 #include <unwind.h>
19
20 G_BEGIN_DECLS
21
22 /*
23  * Keep in sync with the enum in utils/mono-memory-model.h.
24  */
25 typedef enum {
26         LLVM_BARRIER_NONE = 0,
27         LLVM_BARRIER_ACQ = 1,
28         LLVM_BARRIER_REL = 2,
29         LLVM_BARRIER_SEQ = 3,
30 } BarrierKind;
31
32 typedef enum {
33         LLVM_ATOMICRMW_OP_XCHG = 0,
34         LLVM_ATOMICRMW_OP_ADD = 1,
35 } AtomicRMWOp;
36
37 typedef unsigned char * (AllocCodeMemoryCb) (LLVMValueRef function, int size);
38 typedef void (FunctionEmittedCb) (LLVMValueRef function, void *start, void *end);
39 typedef void (ExceptionTableCb) (void *data);
40 typedef char* (DlSymCb) (const char *name, void **symbol);
41
42 typedef void* MonoEERef;
43
44 MonoEERef
45 mono_llvm_create_ee (LLVMModuleProviderRef MP, AllocCodeMemoryCb *alloc_cb, FunctionEmittedCb *emitted_cb, ExceptionTableCb *exception_cb, DlSymCb *dlsym_cb, LLVMExecutionEngineRef *ee);
46
47 void
48 mono_llvm_dispose_ee (MonoEERef *mono_ee);
49
50 void
51 mono_llvm_optimize_method (MonoEERef mono_ee, LLVMValueRef method);
52
53 void
54 mono_llvm_dump_value (LLVMValueRef value);
55
56 LLVMValueRef
57 mono_llvm_build_alloca (LLVMBuilderRef builder, LLVMTypeRef Ty, 
58                                                 LLVMValueRef ArraySize,
59                                                 int alignment, const char *Name);
60
61 LLVMValueRef 
62 mono_llvm_build_load (LLVMBuilderRef builder, LLVMValueRef PointerVal,
63                                           const char *Name, gboolean is_volatile, BarrierKind barrier);
64
65 LLVMValueRef 
66 mono_llvm_build_aligned_load (LLVMBuilderRef builder, LLVMValueRef PointerVal,
67                                                           const char *Name, gboolean is_volatile, int alignment);
68
69 LLVMValueRef 
70 mono_llvm_build_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
71                                            gboolean is_volatile, BarrierKind kind);
72
73 LLVMValueRef 
74 mono_llvm_build_aligned_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
75                                                            gboolean is_volatile, int alignment);
76
77 LLVMValueRef
78 mono_llvm_build_atomic_rmw (LLVMBuilderRef builder, AtomicRMWOp op, LLVMValueRef ptr, LLVMValueRef val);
79
80 LLVMValueRef
81 mono_llvm_build_fence (LLVMBuilderRef builder, BarrierKind kind);
82
83 void
84 mono_llvm_replace_uses_of (LLVMValueRef var, LLVMValueRef v);
85
86 LLVMValueRef
87 mono_llvm_build_cmpxchg (LLVMBuilderRef builder, LLVMValueRef addr, LLVMValueRef comparand, LLVMValueRef value);
88
89 void
90 mono_llvm_set_must_tail (LLVMValueRef call_ins);
91
92 LLVMValueRef
93 mono_llvm_create_constant_data_array (const uint8_t *data, int len);
94
95 void
96 mono_llvm_set_is_constant (LLVMValueRef global_var);
97
98 void
99 mono_llvm_set_preserveall_cc (LLVMValueRef func);
100
101 void
102 mono_llvm_set_call_preserveall_cc (LLVMValueRef call);
103
104 _Unwind_Reason_Code 
105 mono_debug_personality (int a, _Unwind_Action b,
106         uint64_t c, struct _Unwind_Exception *d, struct _Unwind_Context *e);
107
108 void
109 mono_llvm_set_unhandled_exception_handler (void);
110
111 void
112 default_mono_llvm_unhandled_exception (void);
113
114 void
115 mono_llvm_create_di_compile_unit (LLVMModuleRef module);
116
117 G_END_DECLS
118
119 #endif /* __MONO_MINI_LLVM_CPP_H__ */