rustc_codegen_cranelift
rustc_codegen_cranelift copied to clipboard
Using rustc_codegen_cranelift as dependency?
I would like to create meta-tracing JIT library that will work like holyjit or RPython and there was a way of interpreting Rust MIR but now I think that it will be much simpler to interpret Cranelift IR so I'm wondering if it is possible to use rustc_codegen_cranelift to translate some Rust function MIR into Cranelift IR and then somehow obtain this IR? I've tried to look at source code but haven't found API for this
Currently codegen_fn, codegen_static, CodegenCx and driver::predefine_mono_items are private. I think those should be enough for what you want. I can make them public if you want, but I won't make any api guarantees, so make sure to pin a specific commit using rustc_codegen_cranelift = { git = "...", rev = "..." }.
What I've thought of is to write rustc plugin which will invoke rustc_codegen_cranelift on specified function and then save Cranelift IR in some of data sections to be interpreted and traced at runtime , is this possible?
That would also be possible. Except for the keeping it available at runtime at runtime part that would be pretty much equivalent to how cg_llvm embeds LLVM bitcode into object files.
By the way have you seen https://github.com/softdevteam/yk?
I have seen ykrustc, yes. It uses Intel hardware tracing which is not portable across CPUs. I belive that interpreting Cranelift IR is much easier and more portable way of doing meta-tracing JIT
I can try to implement this in a couple of days.
That would be awesome! Thanks!