[System.Runtime.InteropServices.RuntimeInformation] Updated to reference copied files...
[mono-project.git] / mono / mini / mini-llvm-loaded.c
blobd0f3efbe8b1b052eaee9a01f3e09250f6469fff5
1 /*
2 * Handle the differences between the llvm backend beeing embedded
3 * or loaded at runtime.
4 */
6 #include "mini.h"
7 #include "mini-llvm.h"
9 #ifdef MONO_LLVM_LOADED
11 typedef struct {
12 void (*init)(void);
13 void (*cleanup)(void);
14 void (*emit_method)(MonoCompile *cfg);
15 void (*emit_call)(MonoCompile *cfg, MonoCallInst *call);
16 void (*create_aot_module)(MonoAssembly *assembly, const char *global_prefix, gboolean emit_dwarf, gboolean static_link, gboolean llvm_only);
17 void (*emit_aot_module)(const char *filename, const char *cu_name);
18 void (*check_method_supported)(MonoCompile *cfg);
19 void (*emit_aot_file_info)(MonoAotFileInfo *info, gboolean has_jitted_code);
20 void (*emit_aot_data)(const char *symbol, guint8 *data, int data_len);
21 void (*free_domain_info)(MonoDomain *domain);
22 void (*create_vars)(MonoCompile *cfg);
23 } LoadedBackend;
25 static LoadedBackend backend;
27 void
28 mono_llvm_init (void)
30 backend.init ();
33 void
34 mono_llvm_cleanup (void)
36 backend.cleanup ();
39 void
40 mono_llvm_emit_method (MonoCompile *cfg)
42 backend.emit_method (cfg);
45 void
46 mono_llvm_emit_call (MonoCompile *cfg, MonoCallInst *call)
48 backend.emit_call (cfg, call);
51 void
52 mono_llvm_create_aot_module (MonoAssembly *assembly, const char *global_prefix, gboolean emit_dwarf, gboolean static_link, gboolean llvm_only)
54 backend.create_aot_module (assembly, global_prefix, emit_dwarf, static_link, llvm_only);
57 void
58 mono_llvm_emit_aot_module (const char *filename, const char *cu_name)
60 backend.emit_aot_module (filename, cu_name);
63 void
64 mono_llvm_check_method_supported (MonoCompile *cfg)
66 backend.check_method_supported (cfg);
69 void
70 mono_llvm_free_domain_info (MonoDomain *domain)
72 /* This is called even when llvm is not enabled */
73 if (backend.free_domain_info)
74 backend.free_domain_info (domain);
77 void
78 mono_llvm_emit_aot_file_info (MonoAotFileInfo *info, gboolean has_jitted_code)
80 backend.emit_aot_file_info (info, has_jitted_code);
83 void
84 mono_llvm_emit_aot_data (const char *symbol, guint8 *data, int data_len)
86 backend.emit_aot_data (symbol, data, data_len);
89 void
90 mono_llvm_create_vars (MonoCompile *cfg)
92 backend.create_vars (cfg);
95 int
96 mono_llvm_load (const char* bpath)
98 char *err = NULL;
99 MonoDl *llvm_lib = mono_dl_open_runtime_lib ("mono-llvm", MONO_DL_LAZY, &err);
101 if (!llvm_lib) {
102 g_warning ("llvm load failed: %s\n", err);
103 g_free (err);
104 return FALSE;
107 err = mono_dl_symbol (llvm_lib, "mono_llvm_init", (void**)&backend.init);
108 if (err) goto symbol_error;
109 err = mono_dl_symbol (llvm_lib, "mono_llvm_cleanup", (void**)&backend.cleanup);
110 if (err) goto symbol_error;
111 err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_method", (void**)&backend.emit_method);
112 if (err) goto symbol_error;
113 err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_call", (void**)&backend.emit_call);
114 if (err) goto symbol_error;
115 err = mono_dl_symbol (llvm_lib, "mono_llvm_create_aot_module", (void**)&backend.create_aot_module);
116 if (err) goto symbol_error;
117 err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_module", (void**)&backend.emit_aot_module);
118 if (err) goto symbol_error;
119 err = mono_dl_symbol (llvm_lib, "mono_llvm_check_method_supported", (void**)&backend.check_method_supported);
120 if (err) goto symbol_error;
121 err = mono_dl_symbol (llvm_lib, "mono_llvm_free_domain_info", (void**)&backend.free_domain_info);
122 if (err) goto symbol_error;
123 err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_file_info", (void**)&backend.emit_aot_file_info);
124 if (err) goto symbol_error;
125 err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_data", (void**)&backend.emit_aot_data);
126 if (err) goto symbol_error;
127 err = mono_dl_symbol (llvm_lib, "mono_llvm_create_vars", (void**)&backend.create_vars);
128 if (err) goto symbol_error;
129 return TRUE;
130 symbol_error:
131 g_warning ("llvm symbol load failed: %s\n", err);
132 g_free (err);
133 return FALSE;
136 #else
139 mono_llvm_load (const char* bpath)
141 return TRUE;
144 #endif /* MONO_LLVM_LOADED */