Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h
Show All 40 Lines | |||||
public: | public: | ||||
using ObjLayerT = LegacyRTDyldObjectLinkingLayer; | using ObjLayerT = LegacyRTDyldObjectLinkingLayer; | ||||
using CompileLayerT = LegacyIRCompileLayer<ObjLayerT, SimpleCompiler>; | using CompileLayerT = LegacyIRCompileLayer<ObjLayerT, SimpleCompiler>; | ||||
KaleidoscopeJIT() | KaleidoscopeJIT() | ||||
: Resolver(createLegacyLookupResolver( | : Resolver(createLegacyLookupResolver( | ||||
ES, | ES, | ||||
[this](const std::string &Name) { return findMangledSymbol(Name); }, | [this](const std::string &Name) { return findMangledSymbol(Name); }, | ||||
[](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })), | [](Error Err) { llvm_cantFail(std::move(Err), "lookupFlags failed"); })), | ||||
TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), | TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), | ||||
ObjectLayer(AcknowledgeORCv1Deprecation, ES, | ObjectLayer(AcknowledgeORCv1Deprecation, ES, | ||||
[this](VModuleKey) { | [this](VModuleKey) { | ||||
return ObjLayerT::Resources{ | return ObjLayerT::Resources{ | ||||
std::make_shared<SectionMemoryManager>(), Resolver}; | std::make_shared<SectionMemoryManager>(), Resolver}; | ||||
}), | }), | ||||
CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer, | CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer, | ||||
SimpleCompiler(*TM)) { | SimpleCompiler(*TM)) { | ||||
llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr); | llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr); | ||||
} | } | ||||
TargetMachine &getTargetMachine() { return *TM; } | TargetMachine &getTargetMachine() { return *TM; } | ||||
VModuleKey addModule(std::unique_ptr<Module> M) { | VModuleKey addModule(std::unique_ptr<Module> M) { | ||||
auto K = ES.allocateVModule(); | auto K = ES.allocateVModule(); | ||||
cantFail(CompileLayer.addModule(K, std::move(M))); | llvm_cantFail(CompileLayer.addModule(K, std::move(M))); | ||||
ModuleKeys.push_back(K); | ModuleKeys.push_back(K); | ||||
return K; | return K; | ||||
} | } | ||||
void removeModule(VModuleKey K) { | void removeModule(VModuleKey K) { | ||||
ModuleKeys.erase(find(ModuleKeys, K)); | ModuleKeys.erase(find(ModuleKeys, K)); | ||||
cantFail(CompileLayer.removeModule(K)); | llvm_cantFail(CompileLayer.removeModule(K)); | ||||
} | } | ||||
JITSymbol findSymbol(const std::string Name) { | JITSymbol findSymbol(const std::string Name) { | ||||
return findMangledSymbol(mangle(Name)); | return findMangledSymbol(mangle(Name)); | ||||
} | } | ||||
private: | private: | ||||
std::string mangle(const std::string &Name) { | std::string mangle(const std::string &Name) { | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |