Fix the matching of exceptions in llvmonly mode. Add a new AOT_JIT_INFO patch type...
[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 "../metadata/object.h"
19 #include "../metadata/domain-internals.h"
20
21 #include <unwind.h>
22
23 G_BEGIN_DECLS
24
25 /*
26  * Keep in sync with the enum in utils/mono-memory-model.h.
27  */
28 typedef enum {
29         LLVM_BARRIER_NONE = 0,
30         LLVM_BARRIER_ACQ = 1,
31         LLVM_BARRIER_REL = 2,
32         LLVM_BARRIER_SEQ = 3,
33 } BarrierKind;
34
35 typedef enum {
36         LLVM_ATOMICRMW_OP_XCHG = 0,
37         LLVM_ATOMICRMW_OP_ADD = 1,
38 } AtomicRMWOp;
39
40 typedef unsigned char * (AllocCodeMemoryCb) (LLVMValueRef function, int size);
41 typedef void (FunctionEmittedCb) (LLVMValueRef function, void *start, void *end);
42 typedef void (ExceptionTableCb) (void *data);
43 typedef char* (DlSymCb) (const char *name, void **symbol);
44
45 typedef void* MonoEERef;
46
47 MonoEERef
48 mono_llvm_create_ee (LLVMModuleProviderRef MP, AllocCodeMemoryCb *alloc_cb, FunctionEmittedCb *emitted_cb, ExceptionTableCb *exception_cb, DlSymCb *dlsym_cb, LLVMExecutionEngineRef *ee);
49
50 void
51 mono_llvm_dispose_ee (MonoEERef *mono_ee);
52
53 void
54 mono_llvm_optimize_method (MonoEERef mono_ee, LLVMValueRef method);
55
56 void
57 mono_llvm_dump_value (LLVMValueRef value);
58
59 LLVMValueRef
60 mono_llvm_build_alloca (LLVMBuilderRef builder, LLVMTypeRef Ty, 
61                                                 LLVMValueRef ArraySize,
62                                                 int alignment, const char *Name);
63
64 LLVMValueRef 
65 mono_llvm_build_load (LLVMBuilderRef builder, LLVMValueRef PointerVal,
66                                           const char *Name, gboolean is_volatile, BarrierKind barrier);
67
68 LLVMValueRef 
69 mono_llvm_build_aligned_load (LLVMBuilderRef builder, LLVMValueRef PointerVal,
70                                                           const char *Name, gboolean is_volatile, int alignment);
71
72 LLVMValueRef 
73 mono_llvm_build_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
74                                            gboolean is_volatile, BarrierKind kind);
75
76 LLVMValueRef 
77 mono_llvm_build_aligned_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
78                                                            gboolean is_volatile, int alignment);
79
80 LLVMValueRef
81 mono_llvm_build_atomic_rmw (LLVMBuilderRef builder, AtomicRMWOp op, LLVMValueRef ptr, LLVMValueRef val);
82
83 LLVMValueRef
84 mono_llvm_build_fence (LLVMBuilderRef builder, BarrierKind kind);
85
86 void
87 mono_llvm_replace_uses_of (LLVMValueRef var, LLVMValueRef v);
88
89 LLVMValueRef
90 mono_llvm_build_cmpxchg (LLVMBuilderRef builder, LLVMValueRef addr, LLVMValueRef comparand, LLVMValueRef value);
91
92 void
93 mono_llvm_set_must_tail (LLVMValueRef call_ins);
94
95 LLVMValueRef
96 mono_llvm_create_constant_data_array (const uint8_t *data, int len);
97
98 void
99 mono_llvm_set_is_constant (LLVMValueRef global_var);
100
101 void
102 mono_llvm_cpp_throw_exception (gint32 *exc);
103
104 void
105 mono_llvm_cpp_rethrow_exception (gint32 *exc);
106
107 void
108 mono_llvm_rethrow_exception (MonoException *e, gint32 *exc_tag);
109
110 void
111 mono_llvm_throw_exception (MonoException *e, gint32 *exc_tag);
112
113 //gint32
114 //mono_llvm_match_exception (MonoAotModule *amodule, guint32 aot_method_index);
115 //
116 // FIXME: The aot.h header is not cpp-safe. Since this header is shared, I am
117 // temporarily stubbing it out. The real solution is to partition this header at
118 // some point.
119 gint32
120 mono_llvm_match_exception (MonoJitInfo *jinfo, guint32 region_start, guint32 region_end);
121
122 void 
123 mono_llvm_clear_exception (void);
124
125 MonoObject *
126 mono_llvm_load_exception (void);
127
128 void
129 mono_llvm_reset_exception (void);
130
131 _Unwind_Reason_Code 
132 mono_debug_personality (int a, _Unwind_Action b,
133         uint64_t c, struct _Unwind_Exception *d, struct _Unwind_Context *e);
134
135 void
136 mono_llvm_set_unhandled_exception_handler (void);
137
138 void
139 default_mono_llvm_unhandled_exception (void);
140
141 G_END_DECLS
142
143 #endif /* __MONO_MINI_LLVM_CPP_H__ */