本文整理汇总了C++中ExecutionEngine::InstallLazyFunctionCreator方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecutionEngine::InstallLazyFunctionCreator方法的具体用法?C++ ExecutionEngine::InstallLazyFunctionCreator怎么用?C++ ExecutionEngine::InstallLazyFunctionCreator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecutionEngine
的用法示例。
在下文中一共展示了ExecutionEngine::InstallLazyFunctionCreator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseBitcodeFile
void
gen_and_load_llvm_code (mathmap_t *mathmap, char *template_filename, filter_code_t **filter_codes)
{
MemoryBuffer *buffer = MemoryBuffer::getFile(template_filename, NULL);
g_assert(buffer != NULL);
Module *module = ParseBitcodeFile (buffer, NULL);
int i;
filter_t *filter;
assert(module != NULL);
delete buffer;
for (i = 0, filter = mathmap->filters;
filter != 0;
++i, filter = filter->next)
{
if (filter->kind != FILTER_MATHMAP)
continue;
make_init_frame_function(module, filter);
make_init_x_or_y_function(module, filter, init_x_function_name(filter));
make_init_x_or_y_function(module, filter, init_y_function_name(filter));
make_main_filter_function(module, filter);
make_filter_function(module, filter);
}
for (i = 0, filter = mathmap->filters;
filter != 0;
++i, filter = filter->next)
{
filter_code_t *code = filter_codes[i];
code_emitter *emitter;
if (filter->kind != FILTER_MATHMAP)
continue;
g_assert(code->filter == filter);
emitter = new code_emitter (module, filter, code);
try
{
emitter->emit_init_frame_function();
emitter->emit_filter_function();
emitter->emit_main_filter_funcs();
}
catch (compiler_error error)
{
delete emitter;
delete module;
strcpy(error_string, error.info.c_str());
return;
}
delete emitter;
}
PassManager pm;
pm.add(new TargetData(module));
pm.add(createFunctionInliningPass());
pm.add(createInstructionCombiningPass());
pm.add(createReassociatePass());
pm.add(createLowerSetJmpPass());
pm.add(createRaiseAllocationsPass());
pm.add(createGVNPass());
pm.add(createCFGSimplificationPass());
pm.add(createPromoteMemoryToRegisterPass());
pm.add(createGlobalOptimizerPass());
pm.add(createGlobalDCEPass());
pm.run(*module);
#ifdef DEBUG_OUTPUT
module->dump();
verifyModule(*module, PrintMessageAction);
#endif
ExecutionEngine *ee = ExecutionEngine::create (module);
ee->InstallLazyFunctionCreator(lazy_creator);
module_info_t *module_info = g_new0(module_info_t, 1);
module_info->ee = ee;
void *init_frame_fptr = ee->getPointerToFunction(lookup_init_frame_function(module, mathmap->main_filter));
void *main_filter_fptr = ee->getPointerToFunction(lookup_main_filter_function(module, mathmap->main_filter));
void *init_x_fptr = ee->getPointerToFunction(lookup_init_x_function(module, mathmap->main_filter));
void *init_y_fptr = ee->getPointerToFunction(lookup_init_y_function(module, mathmap->main_filter));
g_assert(main_filter_fptr && init_x_fptr && init_y_fptr);
module_info->mathfuncs.llvm_init_frame_func = (llvm_init_frame_func_t)init_frame_fptr;
module_info->mathfuncs.main_filter_func = (llvm_filter_func_t)main_filter_fptr;
module_info->mathfuncs.init_x_func = (init_x_or_y_func_t)init_x_fptr;
module_info->mathfuncs.init_y_func = (init_x_or_y_func_t)init_y_fptr;
mathmap->module_info = module_info;
//.........这里部分代码省略.........