Contributed by merdely on from the pretty-cool-compiler dept.
It is not yet bug-free, but it can compile the i386 userspace. The big benefit of it (apart from that it's BSD licensed, for license geeks :-) is that it is fast, 5-10 times faster than gcc, while still producing reasonable code. The only optimization added so far is a multiple-register-class graph-coloring register allocator, which may be one of the best register allocators today. Conversion to SSA format is also implemented, but not yet the phi function. Not too difficult though, after that strength reduction is high on the list.
It is also quite simple to port, writing the basics for i386 took three hours (hello world) and complete port (pretty much as it is right now) two days.
I have added most of the C99 stuff (it is supposed to be a c99 compiler) but some stuff is still missing, like the ability to do variable declarations anywhere (requires some rewriting of the yacc code).
NetBSD also imported pcc into pkgsrc. The commit message gives a little bit of pcc's history:
The compiler is based on the original Portable C Compiler by S. C. Johnson, written in the late 70's. Even though much of the compiler has been rewritten, some of the basics still remain.
The intention is to write a C99 compiler while still keeping it small, simple, fast and understandable. I think of it as if it shall be able to compile and run on PDP11 (even if it may not happen in reality). But with this in mind it becomes important to think twice about what algorithms are used.
The compiler is conceptually structured in two parts; pass1 which is language-dependent, does parsing, typechecking and build trees, and pass2 which is mostly language-independent.
About 50% of the frontend code and 80% of the backend code has been rewritten. Most stuff is written by me, with the exception of the data-flow analysis part and the SSA conversion code which is written by Peter A Jonsson, and the Mips port that were written as part of a project by undergraduate students at LTU.
Otto Moerbeek (otto@) wrote to the pcc mailing list:
with some minor modifications to our source tree I'm able to build (and run) large parts of bin, sbin, usr.bin and usr.sbin of openbsd. src/lib needs some not yet available features, mostly asm related stuff.
One thing that is missing is __attribute__ support. Currently, our sys/cdefs.h remove those for ! GCC > 2.5. But we will really need it, for at least __packed__ and things like __attribute__((section(".eh_frame"), aligned(4)))
as can be found in src/lib/csu/common_elf/crtbegin.c
But, as an example, complex programs like ksh and ssh run (linked against libs built with gcc)!
Of course the road is still long, but things really look promising,
(Comments are closed)