mir icon indicating copy to clipboard operation
mir copied to clipboard

DO-NOT-MERGE: libgccjit experiment (work-in-progress)

Open davidmalcolm opened this issue 5 years ago • 2 comments

Inspired by Vladimir's talk at LPC, this is a proof-of-concept of populating a libgccjit context from a MIR module, and then compiling it with libgccjit.

This could allow for libgccjit to be used as a tier 2 JIT compiler in conjunction with MIR for tier 1.

Additionally, Vladimir's talk identified a weakness of libgccjit: the difficult of creating the environment through the API. With this approach, C could be compiled to MIR, and then injected into libgccjit.

Right now it's a very rough proof-of-concept that only implements a few instructions and modes. I'm posting it now in order to get early feedback. In particular it doesn't yet support forward references. But it does support compiling trivial binary mir files via libgccjit.

Given that you don't want external deps, I'm not sure where this should ultimately live. Also, I used C++ to simplify the implementation, but could recode it in C if that's a deal-breaker.

davidmalcolm avatar Aug 27 '20 02:08 davidmalcolm

I should also say that this is the first time I've looked in detail at mir, so I've no doubt misunderstood some things.

davidmalcolm avatar Aug 27 '20 02:08 davidmalcolm

Thank you, David! I really appreciate your work. I'll will definitely experiment with this code and I hope in some way MIR->libgccjit will be used in the future.

vnmakarov avatar Aug 27 '20 20:08 vnmakarov