z80 llvm backend

Other misc things
Post Reply
stev47
New member
Posts: 6
Joined: Sun Mar 07, 2010 4:36 pm

z80 llvm backend

Post by stev47 »

hello,

I've read some documents about compilers and asked myself why there hasn't been any effort on trying to use llvm as a compiler-backend.
Considering that llvm already has the PIC16 (an 8bit microprocessor with rather limited capabilities) as a supported target adding z80 to it shouldn't be impossible.

Wouldn't it be a good long term effort to add a z80 target? One could benefit from the optimizations llvm is capable of. Also llvm is an ongoing project and a solid foundation to build a compiler on.

Any thoughts on this?
User avatar
dom
Well known member
Posts: 2091
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I haven't looked at llvm in much depth to be honest, the fact that it's written in C++ puts me off a bit since I don't find it a particularly enjoyable language to write code in.

I've tinkered with vbcc a bit, but there's quite a way to go with it still, the source/diff is here: http://cvs.z88dk.org/cgi-bin/viewvc.cgi/vbcc/?root=vbcc
stev47
New member
Posts: 6
Joined: Sun Mar 07, 2010 4:36 pm

Post by stev47 »

I tried to compare vbcc and llvm a little bit:
it seems that llvm has a by far greater development activity and a helpful community, while vbcc according to its homepage (http://www.compilers.de/vbcc.html) seems to be a one man project.

As far as I skimmed through the llvm documentation it seems that a great deal of the backend-code is generated by a language called TableGen (http://llvm.org/docs/TableGenFundamentals.html) but obviously you wouldn't be able to create a backend without writing C++ code. Though the effort to be placed into a good llvm-backend would most likely be considerably less than you would put into a equivalent compiler which you had to build from scratch as llvm already provides a complete infrastructure.
By defining subtargets in llvm libraries could easily be ported through different z80 platforms ? well, at least it seems to me like that.
In addition to that the existing z88dk peephole optimizer could be reused in llvm.
Last edited by stev47 on Tue Apr 06, 2010 2:04 pm, edited 1 time in total.
User avatar
dom
Well known member
Posts: 2091
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Your summary of the compilers is probably correct.

A new compiler is needed, it's just a question of time which is something I don't have a huge amount of at the moment. Hopefully the summer will give me a bit more time and I'll take a look at llvm.

If you want to set up the basics i.e. get a target building then that would give us a bit of a head start on it.
stev47
New member
Posts: 6
Joined: Sun Mar 07, 2010 4:36 pm

Post by stev47 »

I will be toying around with llvm at this repository: http://github.com/stev47/llvm-z80-testing

Feel free to fork and cooperate at any time but don't expect too much from me tinkering with the backend.
Post Reply