[build] Skips RemoteExecuted bases tests on monodroid
[mono-project.git] / mono / mini / mini-llvm-loaded.c
blobfb1dcac98133843d52cc48ed74aef539240d4340
1 /**
2 * \file
3 * Handle the differences between the llvm backend beeing embedded
4 * or loaded at runtime.
5 */
7 #include "mini.h"
8 #include "mini-llvm.h"
10 #ifdef MONO_LLVM_LOADED
12 typedef struct {
13 void (*init)(void);
14 void (*cleanup)(void);
15 void (*emit_method)(MonoCompile *cfg);
16 void (*emit_call)(MonoCompile *cfg, MonoCallInst *call);
17 void (*create_aot_module)(MonoAssembly *assembly, const char *global_prefix, int initial_got_size, gboolean emit_dwarf, gboolean static_link, gboolean llvm_only);
18 void (*emit_aot_module)(const char *filename, const char *cu_name);
19 void (*check_method_supported)(MonoCompile *cfg);
20 void (*emit_aot_file_info)(MonoAotFileInfo *info, gboolean has_jitted_code);
21 void (*emit_aot_data)(const char *symbol, guint8 *data, int data_len);
22 void (*free_domain_info)(MonoDomain *domain);
23 void (*create_vars)(MonoCompile *cfg);
24 } LoadedBackend;
26 static LoadedBackend backend;
28 void
29 mono_llvm_init (void)
31 backend.init ();
34 void
35 mono_llvm_cleanup (void)
37 backend.cleanup ();
40 void
41 mono_llvm_emit_method (MonoCompile *cfg)
43 backend.emit_method (cfg);
46 void
47 mono_llvm_emit_call (MonoCompile *cfg, MonoCallInst *call)
49 backend.emit_call (cfg, call);
52 void
53 mono_llvm_create_aot_module (MonoAssembly *assembly, const char *global_prefix, int initial_got_size, gboolean emit_dwarf, gboolean static_link, gboolean llvm_only)
55 backend.create_aot_module (assembly, global_prefix, initial_got_size, emit_dwarf, static_link, llvm_only);
58 void
59 mono_llvm_emit_aot_module (const char *filename, const char *cu_name)
61 backend.emit_aot_module (filename, cu_name);
64 void
65 mono_llvm_check_method_supported (MonoCompile *cfg)
67 backend.check_method_supported (cfg);
70 void
71 mono_llvm_free_domain_info (MonoDomain *domain)
73 /* This is called even when llvm is not enabled */
74 if (backend.free_domain_info)
75 backend.free_domain_info (domain);
78 void
79 mono_llvm_emit_aot_file_info (MonoAotFileInfo *info, gboolean has_jitted_code)
81 backend.emit_aot_file_info (info, has_jitted_code);
84 void
85 mono_llvm_emit_aot_data (const char *symbol, guint8 *data, int data_len)
87 backend.emit_aot_data (symbol, data, data_len);
90 void
91 mono_llvm_create_vars (MonoCompile *cfg)
93 backend.create_vars (cfg);
96 int
97 mono_llvm_load (const char* bpath)
99 char *err = NULL;
100 MonoDl *llvm_lib = mono_dl_open_runtime_lib ("mono-llvm", MONO_DL_LAZY, &err);
102 if (!llvm_lib) {
103 g_warning ("llvm load failed: %s\n", err);
104 g_free (err);
105 return FALSE;
108 err = mono_dl_symbol (llvm_lib, "mono_llvm_init", (void**)&backend.init);
109 if (err) goto symbol_error;
110 err = mono_dl_symbol (llvm_lib, "mono_llvm_cleanup", (void**)&backend.cleanup);
111 if (err) goto symbol_error;
112 err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_method", (void**)&backend.emit_method);
113 if (err) goto symbol_error;
114 err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_call", (void**)&backend.emit_call);
115 if (err) goto symbol_error;
116 err = mono_dl_symbol (llvm_lib, "mono_llvm_create_aot_module", (void**)&backend.create_aot_module);
117 if (err) goto symbol_error;
118 err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_module", (void**)&backend.emit_aot_module);
119 if (err) goto symbol_error;
120 err = mono_dl_symbol (llvm_lib, "mono_llvm_check_method_supported", (void**)&backend.check_method_supported);
121 if (err) goto symbol_error;
122 err = mono_dl_symbol (llvm_lib, "mono_llvm_free_domain_info", (void**)&backend.free_domain_info);
123 if (err) goto symbol_error;
124 err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_file_info", (void**)&backend.emit_aot_file_info);
125 if (err) goto symbol_error;
126 err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_data", (void**)&backend.emit_aot_data);
127 if (err) goto symbol_error;
128 err = mono_dl_symbol (llvm_lib, "mono_llvm_create_vars", (void**)&backend.create_vars);
129 if (err) goto symbol_error;
130 return TRUE;
131 symbol_error:
132 g_warning ("llvm symbol load failed: %s\n", err);
133 g_free (err);
134 return FALSE;
137 #else
140 mono_llvm_load (const char* bpath)
142 return TRUE;
145 #endif /* MONO_LLVM_LOADED */