3 ms·
> There should be a compiler somewhere which combines easy porting with adequate code generation[1] > [1] I'm actually working on this. Anything to share yet?
by speps 10y ago
> There should be a compiler somewhere which combines easy porting with adequate code generation[1]
> [1] I'm actually working on this.
Anything to share yet? Will it take LLVM IR as input or are you targeting a specific language? I'm very interested. So far, I found only the Plan 9 C compilers seemed to have relatively straightforward code as it was designed for this.
- slrz 10y agoThe Plan 9 C compilers are nice as they're so small. Still, the backend creation process would look roughly similar, at least from where I'm standing: copy a roughly similar one and beat on it for some time. The difference is in duration, though. You're unlikely to pound on it for several years until you get something working.
- david-given 10y agoI have mostly-working code --- but the register allocator I was using turns out to be pretty pants, so it's generating lousy code and is nowhere ready to look at yet. I'm taking time off to learn about graph colouring to try and do a proper job. (Turns out graph colouring on irregular architectures is kinda exciting, and not in a good way.) It's not actually based on LLVM at all; I'm working with a completely different (and simpler) compiler suite, albeit using some of the same principles. The code quality is never going to be good, but I'm hoping the end result will allow a compiler port to any random relatively sane architecture in only two source files.
- tom_mellior 10y ago> Turns out graph colouring on irregular architectures is kinda exciting, and not in a good way. Have you looked into PBQP register allocation? It's almost as simple as basic graph coloring but handles irregularities in a nice and disciplined way.
- qznc 10y agoI helped building the one in libfirm and I agree. The x86 architecture is quite regular and we have not used it for others in practice. However, for all irregularities I have come across I could immediately see how to model it in theory.
- tom_mellior 10y agoOh, I thought PBQP was the only register allocator in libfirm. What do you use for other architectures?
- qznc 10y agoThe default is a graph coloring algorithm. Well actually a "recoloring" algorithm due to its SSA-based nature. There is also an ILP one, which is only useful for comparison.