Re: Compiler design
Well... compiler design is a tough issue. Let us clarify some issues here.
1. Compilers for stack computers (or single-accumulator ones)
These are the more easy to implement. They have been documented in some books (like "Compilers and Compiler Generators). Since no register allocation is regarded, you have significantly less job to do.
2. Simple compilers for RISCs
An example is LCC from Princeton. Actually, not that easy but in order to get a new backend working you only have to modify the .md file (machine description file). About 7-8 backends are available globally, 4 of them come within the original distribution. You can't easily change the register allocation approach, while code generation is only done via dynamic programming (as in Aho or Hanson books if i recall).
3. Production-quality compilers
GCC mainly. Very tough mother, lots of host/targets configurations, some of them in alpha state. Extremely good code regarding size. Doesn't get much better than that. Very tough to extend. It is so big and bloated that it has been split to "development branches". At least 10 of them!!!
4. Research compilers
Research compilers are meant to be either one or both things: retargetable and extendable.
Retargetable means you can (with no indespeakable pain) add support for new targets.
Extendable means you can add both analysis and optimization passes.
Such compilers are SUIF and derivatives, COINS, ML-RISC. Major research work happens with SUIF and IMPACT (a research compiler for VLIW architecture of HP named PlayDoh)
To sum up:
5. Good books
The Aho-Ullman book (Compilers - Principles ...) Known as "The Red Dragon" book. If you master this beau, i must i'm amazed.
2-3 free books out there. Like the Terry book (Compilers and Compiler Generators), "Engineering a Compiler" etc
The LCC book
6. Compilers
GCC:
https://gcc.gnu.org. Tough mamma
LCC:
https://www.cs.princeton.edu/software/lcc/
SUIF:
https://suif.stanford.edu
PS: The most difficult part is to get done a working backend. Difficulty rises proportionally to its differences against a commodity RISC.
Best regards
the_penetrator©