Hi Pawel,
I believe that an early (working) version of Orc is in the 3.6 release, and work on Orc is continuing on trunk.
The MCJIT API (or at least the ExecutionEngine API) will stay with us for some time, but hopefully only the API. I am hoping that the MCJIT class itself can be deprecated in the future in favor of the OrcMCJITReplacement class. Given that, I’d rather not expose MCJIT directly: Any work we do there will have to be duplicated in OrcMCJITReplacement if everything goes to plan.
Orc should be a good fit for any MCJIT client: It was designed with MCJIT’s use-cases in mind, and built on the same conceptual framework (i.e. replicating the static pipeline by linking object files in memory). It’s aim is almost exactly what you’ve described: To tidy MCJIT up and expose the internals so that people can add new features.
I’d be interested to hear how you go porting your project to Orc, and I would be happy to help out where I can. What features of MCJIT are you using now? And what do you want to add? I’d suggest checking out the Orc/Kaleidoscope tutorials (see llvm/examples/Kaleidoscope/Orc/) and the OrcMCJITReplacement class (see llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.) to get an idea of what features are available now. It sounds like you’ll want to add to this, but then that’s the purpose of these new APIs.
As a sales pitch for Orc, I’ve included the definition of the initial JIT from the Orc/Kaleidoscope tutorials below. As you can see, you can get a functioning “custom” JIT up and running with a page of code. This basic JIT just lets you throw LLVM modules at it and execute functions from them. Starting from this point, with 149 lines worth of changes*, you can build a JIT that lazily compiles functions from ASTs on first call (no need to even IRGen up front).
Cheers,
Lang.
- As reported by:
diff examples/Kaleidoscope/Orc/{initial,fully_lazy}/toy.cpp | wc -l
class KaleidoscopeJIT {
public:
typedef ObjectLinkingLayer<> ObjLayerT;
typedef IRCompileLayer CompileLayerT;
typedef CompileLayerT::ModuleSetHandleT ModuleHandleT;
KaleidoscopeJIT(TargetMachine &TM)
: Mang(TM.getDataLayout()),
CompileLayer(ObjectLayer, SimpleCompiler™) {}
std::string mangle(const std::string &Name) {
std::string MangledName;
{
raw_string_ostream MangledNameStream(MangledName);
Mang.getNameWithPrefix(MangledNameStream, Name);
}
return MangledName;
}
ModuleHandleT addModule(std::unique_ptr M) {
auto MM = createLookasideRTDyldMM(
[&](const std::string &Name) {
return findSymbol(Name).getAddress();
},
[](const std::string &S) { return 0; } );
return CompileLayer.addModuleSet(singletonSet(std::move(M)), std::move(MM));
}
void removeModule(ModuleHandleT H) { CompileLayer.removeModuleSet(H); }
JITSymbol findSymbol(const std::string &Name) {
return CompileLayer.findSymbol(Name, true);
}
JITSymbol findUnmangledSymbol(const std::string Name) {
return findSymbol(mangle(Name));
}
private:
Mangler Mang;
ObjLayerT ObjectLayer;
CompileLayerT CompileLayer;
};