Code Generator Trainer
Code Generator Trainer (CGTrainer)
Developing a C compiler for a new (or old) target processor is one of the greatest and most rewarding software engineering projects imaginable. It is also challenging and daunting. This is where the Code Generator Trainer (CGTrainer), which is included in the SuperTest Compiler Test Suite, comes in.
The assumption is that this compiler is not written from scratch. It will be using an existing compiler development platform, either open source or proprietary, that already has a front-end, optimizations and a more or less retargetable code generator. What has to be done is writing a code generator for the new target processor. SuperTest’s Code Generation Trainer suite is going to make this project run smooth, efficiently and with a lot of fun on top of that.
CGtrainer consists of nearly one thousand test files split over 25 carefully constructed levels aimed at boot-strapping new compiler development. Each level addresses a specific capability of the code generator. Level 0 is there to set up the minimal interface that is needed to run the tests. The next levels introduce simple integer arithmetic, conversions, pointers, addressing modes for structures, register allocation, control flow and calling conventions. Beyond that are levels dealing with characters and shorts, long long arithmetic and varargs.
Each level is constructed to build upon the groundwork of the previous levels. This way, the code generator development progresses one logical step at a time. It gets you a better compiler, faster.
By the time the compiler passes the final level, it is ready to take on SuperTest’s big guns: the conformance suites that validate the front-end, optimization correctness and more nitty gritty details of code generation. There will be more work to do: add more features, improve efficiency, etc. You can be sure that this work builds on the solid foundations laid out by SuperTest’s CGtrainer.
Want to get your hands on CGtrainer and start developing your code generator now? Get the SuperTest demo. You will find the first few levels included for free.