Hi LLVM folks,
Attached with this email, you will find a patch not directly applicable (it doesn’t compile like this) which (try to) enhance the structure of a possible JIT with the MC framework.
Basically :
-
MCJIT :
-
Main class implementing ExecutionEngine interface
-
owns and creates :
-
a MemoryManager (will be a reuse of the JITMemoryManager mechanism)
-
a MCJITStreamer
-
a PassManager for scheduling of an AsmPrinter (MCLowering) using the streamer
-
MCJITStreamer
-
owns and creates :
-
a MCAssember
-
a MCJITObjectWriter
-
a mem_raw_ostream
-
knows :
-
the MCJIT : to give it to the object writer (for mapping)
-
the MemoryManager : to give it to the object writer (for memory claiming)
-
MCJITObjectWriter
-
knows :
-
the MCJIT : for mapping GlobalVariable <-> native address
-
the MemoryManager : for claiming memory
-
mem_raw_ostream
-
The ostream interface to write data in memory
-
Currently using a MemoryBlock but will probably be changed for matching JITMemoryManager structure
Another point of interest is how the current mappings are implemented in the ExecutionEngine.
When applying fixups in the ObjectWriter, we get a symbol name from a MCSymbol. With the current mappings the Writer is forced to know the Module, to search for Global named like the MCSymbol. This global is then used to retrieve a native address.
It will be probably more efficient to use a direct mapping StringRef <-> native address. We can keep an overloaded method for GlobalVariable <-> native address, if this is necessary for compatibility or easiness of use.
What do you think ?
Olivier.
mc_jit_structure.diff (21.3 KB)