Skip to content

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

Open
davidmalcolm wants to merge 4 commits intovnmakarov:v0_masterfrom
davidmalcolm:libgccjit-experiment
Open

DO-NOT-MERGE: libgccjit experiment (work-in-progress)#109
davidmalcolm wants to merge 4 commits intovnmakarov:v0_masterfrom
davidmalcolm:libgccjit-experiment

Conversation

@davidmalcolm
Copy link
Copy Markdown

@davidmalcolm davidmalcolm commented Aug 27, 2020

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.

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.  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
Copy link
Copy Markdown
Author

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.

@vnmakarov
Copy link
Copy Markdown
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants