当前位置: 首页>>代码示例>>C++>>正文


C++ ExecutionEngine::InstallLazyFunctionCreator方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:WoodMath,项目名称:mathmap,代码行数:101,代码来源:llvm.cpp


注:本文中的ExecutionEngine::InstallLazyFunctionCreator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。