2 * Handle the differences between the llvm backend beeing embedded
3 * or loaded at runtime.
9 #ifdef MONO_LLVM_LOADED
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
);
25 static LoadedBackend backend
;
34 mono_llvm_cleanup (void)
40 mono_llvm_emit_method (MonoCompile
*cfg
)
42 backend
.emit_method (cfg
);
46 mono_llvm_emit_call (MonoCompile
*cfg
, MonoCallInst
*call
)
48 backend
.emit_call (cfg
, call
);
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
);
58 mono_llvm_emit_aot_module (const char *filename
, const char *cu_name
)
60 backend
.emit_aot_module (filename
, cu_name
);
64 mono_llvm_check_method_supported (MonoCompile
*cfg
)
66 backend
.check_method_supported (cfg
);
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
);
78 mono_llvm_emit_aot_file_info (MonoAotFileInfo
*info
, gboolean has_jitted_code
)
80 backend
.emit_aot_file_info (info
, has_jitted_code
);
84 mono_llvm_emit_aot_data (const char *symbol
, guint8
*data
, int data_len
)
86 backend
.emit_aot_data (symbol
, data
, data_len
);
90 mono_llvm_create_vars (MonoCompile
*cfg
)
92 backend
.create_vars (cfg
);
96 mono_llvm_load (const char* bpath
)
99 MonoDl
*llvm_lib
= mono_dl_open_runtime_lib ("mono-llvm", MONO_DL_LAZY
, &err
);
102 g_warning ("llvm load failed: %s\n", err
);
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
;
131 g_warning ("llvm symbol load failed: %s\n", err
);
139 mono_llvm_load (const char* bpath
)
144 #endif /* MONO_LLVM_LOADED */