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?
z80 llvm backend
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
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
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.
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.
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.
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.
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.
Feel free to fork and cooperate at any time but don't expect too much from me tinkering with the backend.