本文整理汇总了C++中ExecutionEngine::addModule方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecutionEngine::addModule方法的具体用法?C++ ExecutionEngine::addModule怎么用?C++ ExecutionEngine::addModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecutionEngine
的用法示例。
在下文中一共展示了ExecutionEngine::addModule方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addCygMingExtraModule
// On Mingw and Cygwin, an external symbol named '__main' is called from the
// generated 'main' function to allow static intialization. To avoid linking
// problems with remote targets (because lli's remote target support does not
// currently handle external linking) we add a secondary module which defines
// an empty '__main' function.
static void addCygMingExtraModule(ExecutionEngine &EE, LLVMContext &Context,
StringRef TargetTripleStr) {
IRBuilder<> Builder(Context);
Triple TargetTriple(TargetTripleStr);
// Create a new module.
std::unique_ptr<Module> M = make_unique<Module>("CygMingHelper", Context);
M->setTargetTriple(TargetTripleStr);
// Create an empty function named "__main".
Function *Result;
if (TargetTriple.isArch64Bit()) {
Result = Function::Create(
TypeBuilder<int64_t(void), false>::get(Context),
GlobalValue::ExternalLinkage, "__main", M.get());
} else {
Result = Function::Create(
TypeBuilder<int32_t(void), false>::get(Context),
GlobalValue::ExternalLinkage, "__main", M.get());
}
BasicBlock *BB = BasicBlock::Create(Context, "__main", Result);
Builder.SetInsertPoint(BB);
Value *ReturnVal;
if (TargetTriple.isArch64Bit())
ReturnVal = ConstantInt::get(Context, APInt(64, 0));
else
ReturnVal = ConstantInt::get(Context, APInt(32, 0));
Builder.CreateRet(ReturnVal);
// Add this new module to the ExecutionEngine.
EE.addModule(std::move(M));
}
示例2: initEE
void initEE(std::unique_ptr<Module> Owner) {
string ErrStr;
if (EE == NULL) {
RTDyldMM = new SectionMemoryManager();
EE = EngineBuilder(std::move(Owner))
.setEngineKind(EngineKind::JIT)
.setErrorStr(&ErrStr)
.setVerifyModules(true)
.setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager>(RTDyldMM))
.setOptLevel(CodeGenOpt::Default)
.create();
} else
EE->addModule(std::move(Owner));
if (ErrStr.length() != 0)
cerr << "Create Engine Error" << endl << ErrStr << endl;
EE->finalizeObject();
}
示例3: initEE
void initEE(std::unique_ptr<Module> Owner) {
if (EE == NULL)
EE = EngineBuilder(std::move(Owner)).create();
else
EE->addModule(std::move(Owner));
}