3 * Handle the differences between the llvm backend beeing embedded
4 * or loaded at runtime.
10 #ifdef MONO_LLVM_LOADED
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
);
26 static LoadedBackend backend
;
35 mono_llvm_cleanup (void)
41 mono_llvm_emit_method (MonoCompile
*cfg
)
43 backend
.emit_method (cfg
);
47 mono_llvm_emit_call (MonoCompile
*cfg
, MonoCallInst
*call
)
49 backend
.emit_call (cfg
, call
);
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
);
59 mono_llvm_emit_aot_module (const char *filename
, const char *cu_name
)
61 backend
.emit_aot_module (filename
, cu_name
);
65 mono_llvm_check_method_supported (MonoCompile
*cfg
)
67 backend
.check_method_supported (cfg
);
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
);
79 mono_llvm_emit_aot_file_info (MonoAotFileInfo
*info
, gboolean has_jitted_code
)
81 backend
.emit_aot_file_info (info
, has_jitted_code
);
85 mono_llvm_emit_aot_data (const char *symbol
, guint8
*data
, int data_len
)
87 backend
.emit_aot_data (symbol
, data
, data_len
);
91 mono_llvm_create_vars (MonoCompile
*cfg
)
93 backend
.create_vars (cfg
);
97 mono_llvm_load (const char* bpath
)
100 MonoDl
*llvm_lib
= mono_dl_open_runtime_lib ("mono-llvm", MONO_DL_LAZY
, &err
);
103 g_warning ("llvm load failed: %s\n", err
);
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
;
132 g_warning ("llvm symbol load failed: %s\n", err
);
140 mono_llvm_load (const char* bpath
)
145 #endif /* MONO_LLVM_LOADED */