Off-topic: a new JIT compiler for C with LLVM backend

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Off-topic: a new JIT compiler for C with LLVM backend

Dibyendu Majumdar
Hi,

One of the features in Ravi is a binding for LLVM api, so that you can
construct LLVM IR from within Ravi. However, LLVM IR coding is very
tedious so I am not surprised that I haven't heard anyone trying this
out. So for a while I have been thinking of a way to provide an easier
approach to this.

Terra (http://terralang.org/)  has taken the approach for creating a C
like language that is essentially C but has Lua like syntax to achieve
a similar goal.

I love C (have loved it since I first learnt it) and so I thought it
better to provide a C language based approach. I have been spending
some time on exactly this.

dmr_C (https://github.com/dibyendumajumdar/dmr_c) is an attempt to
create a light weight C front-end for LLVM. It is based on a project
called Sparse that is not as well known as Linux or Git - but was
created by Linus Torvalds several years ago.

The project is making good progress. The next step is to create some
bindings for Ravi/Lua.

I think once fully implemented there are interesting possibilities.
The library has a full fledged C pre-processor, parser, and has its
own SSA IR. The API is a bit low level, so work is needed to expose
the data structures in an easier manner.

I thought folks here might find it interesting - please accept my
apologies for an off topic post.

Thanks and Regards

Dibyendu

Reply | Threaded
Open this post in threaded view
|

Re: Off-topic: a new JIT compiler for C with LLVM backend

Javier Guerra Giraldez
On 30 March 2017 at 13:40, Dibyendu Majumdar <[hidden email]> wrote:
> dmr_C (https://github.com/dibyendumajumdar/dmr_c) is an attempt to
> create a light weight C front-end for LLVM. It is based on a project
> called Sparse that is not as well known as Linux or Git - but was
> created by Linus Torvalds several years ago.


so.... what does it do?   is it like TCC but with LLVM strength?

--
Javier

Reply | Threaded
Open this post in threaded view
|

Re: Off-topic: a new JIT compiler for C with LLVM backend

Dibyendu Majumdar
Hi Javier,

On 30 March 2017 at 13:54, Javier Guerra Giraldez <[hidden email]> wrote:
> On 30 March 2017 at 13:40, Dibyendu Majumdar <[hidden email]> wrote:
>> dmr_C (https://github.com/dibyendumajumdar/dmr_c) is an attempt to
>> create a light weight C front-end for LLVM. It is based on a project
>> called Sparse that is not as well known as Linux or Git - but was
>> created by Linus Torvalds several years ago.
>
>
> so.... what does it do?   is it like TCC but with LLVM strength?
>

I am not that familiar with TCC - though I did consider it for this
use case but the GPL license put me off.

TCC has fast compilation as its goal. The Sparse library is not
focused on compilation speed (although I think it is fast) and is also
different in that it produces an SSA IR of its own, and has an
optimization phase as well. The LLVM backend transforms the Sparse IR
to LLVM IR.

But yes I suppose that having LLVM backend means one can target many
platforms, and also benefit from further optimizations in the LLVM
backend.

I plan to build a simpler bacakend using Nanojit or Asmjit - so that
if one doesn't want the heavy weight LLVM backend then there is a
lighter weight solution. This might allow me to use this as the JIT
technology instead of LLVM for Ravi, and achieve much smaller
footprint.

Regards
Dibyendu